Simple Cron job?

Posted on 2003-03-05
Medium Priority
Last Modified: 2013-12-15

I am new to Linux having just installed it to run apache.
I need help to create a cron job that I can run every half an hour to delete all the files in a specific directory that are more than 30 minutes old.

Thanks in advance,

Question by:desperado101
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

heskyttberg earned 200 total points
ID: 8075137
Create a script like this:
find $1 -type f -cmin -30 -exec rm -vf {} \;

#End of file

Put this in /usr/local/bin for instance.
Do chmod 750 or 755 on the file.

Do this:
crontab -e
As user you want tto setup crontab for:
Add the following line:
/30 * * * * {TAB} /usr/local/bin/delete_files.sh /my/dir/where/files/are

/Hans - Erik Skyttberg

Author Comment

ID: 8075936
Lovely, thanks very much for your help!

Featured Post

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month11 days, 8 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question