Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-14-2005, 10:36 AM   #1
LQ Newbie
Registered: Jun 2005
Posts: 9

Rep: Reputation: 0
delete files older than 30 days using cronjob

hi, i am a newbie to all this.

i've recently signed up for a hosting package, which i presume it is on a freebsd or linux. not too sure.

the reason why i came here it was because the both system has the cronjob feature, i guess.

anyway. i run a file uploading site call

what i want to do is some sort of cron job comand or tiney php or cgi script that deletes file if it is older than 30 days in sepecific folders.

someone please help me
Old 06-14-2005, 11:11 AM   #2
LQ Guru
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Try something like:
find /path/to/files -mtime +30 -exec rm  {}\;
Change /path/to/files as you need, of course. -mtime +30 means "modified 30 or more days ago" and the "-exec rm {}\;" deletes the file.
Old 06-14-2005, 11:49 AM   #3
LQ Newbie
Registered: Jun 2005
Posts: 9

Original Poster
Rep: Reputation: 0
omg, that code looks too good to be tru. lolz. i was almost about to buy the script caled Auto Delete II from some next company. lolz

thank you very much for such valuable code.

i o u one buddy

once again, thank u
Old 06-14-2005, 12:14 PM   #4
Senior Member
Registered: May 2002
Location: Melbourne Australia
Distribution: it died/ macosx
Posts: 2,478

Rep: Reputation: 50

these threads are ones I started ages ago- perhaps they did not turn up in your search- if the search was set to look at a year or newer. Helped me, might help you.

Old 06-14-2005, 02:33 PM   #5
LQ Newbie
Registered: Jun 2005
Posts: 9

Original Poster
Rep: Reputation: 0

i did search for da keyword cron, but, me being the noob, i had no clue what everyone was talking about.

somehow the previous code kinda made sense. so lets hope it works.

anyway, thanks for your help.
Old 06-14-2005, 02:40 PM   #6
LQ Newbie
Registered: Jun 2005
Posts: 9

Original Poster
Rep: Reputation: 0
btw, thank you for the links


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cron Question - Delete files in a dir older than 48 hours? t3___ Linux - Newbie 5 10-11-2011 03:42 AM
delete files older then a month? Red Squirrel Linux - Software 1 10-05-2005 10:54 PM
delete files in server that is older than 30 days using cronjob latheesan *BSD 2 06-14-2005 12:37 PM
help with a script that deletes files more than X days old BrianK Linux - General 5 06-14-2004 09:05 PM
How to delete pass 30 days email linuxalliance Linux - Networking 3 04-04-2002 07:34 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:45 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration