LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   *BSD (http://www.linuxquestions.org/questions/%2Absd-17/)
-   -   delete files in server that is older than 30 days using cronjob (http://www.linuxquestions.org/questions/%2Absd-17/delete-files-in-server-that-is-older-than-30-days-using-cronjob-333480/)

latheesan 06-14-2005 10:38 AM

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 mp3host.info

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

peter72 06-14-2005 11:49 AM

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:

Code:

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.

Pete

finegan 06-14-2005 12:37 PM

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.

http://www.linuxquestions.org/rules.php

http://www.linuxquestions.org/questi...hreadid=333477

Cheers,

Finegan


All times are GMT -5. The time now is 08:37 AM.