Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Other *NIX Forums > *BSD
User Name
*BSD This forum is for the discussion of all BSD variants.
FreeBSD, OpenBSD, NetBSD, etc.


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

Rep: Reputation: 0
delete files in server that is 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:49 AM   #2
Registered: Oct 2002
Location: Charlottesville, VA
Distribution: Ubuntu (home), SLES (work)
Posts: 196
Blog Entries: 1

Rep: Reputation: 30
Find is the command for you, but depends on what time you want to check. Here are some examples cut from the man page:

-atime n
File was last accessed n*24 hours ago.
-mtime n
File’s data was last modified n*24 hours ago.
-ctime n
File’s status was last changed n*24 hours ago.

So, using one of the time options you would do:

find /data/path -mtime 30 -exec rm {} \;
But you may want to experiment a bit with ls to:

[CODE]find /data/path -mtime 30 -exec ls -l {} \;[\CODE]

Hope it helps.

Old 06-14-2005, 12:37 PM   #3
LQ Guru
Registered: Aug 2001
Location: Dublin, Ireland
Distribution: Slackware
Posts: 5,700

Rep: Reputation: 58
Please do not post the same thread in more than one forum. Picking the most relevant forum and posting it once there makes it easier for other members to help you and keeps the discussion all in one place.



Closed Thread

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 older than 30 days using cronjob latheesan Linux - Newbie 5 06-14-2005 02:40 PM
Files delete from SAMBA server klmn1 Linux - General 2 04-17-2004 02:34 AM
How to delete pass 30 days email linuxalliance Linux - Networking 3 04-04-2002 07:34 PM > Forums > Other *NIX Forums > *BSD

All times are GMT -5. The time now is 02:31 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