?
Solved

Simple Cron job?

Posted on 2003-03-05
2
Medium Priority
?
218 Views
Last Modified: 2013-12-15
Hi,

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,

Paul.
0
Comment
Question by:desperado101
[X]
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
2 Comments
 
LVL 8

Accepted Solution

by:
heskyttberg earned 200 total points
ID: 8075137
Create a script like this:
delete_files.sh
#!/bin/bash
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

Regards
/Hans - Erik Skyttberg
0
 

Author Comment

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

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