LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > *BSD
User Name
Password
*BSD This forum is for the discussion of all BSD variants.
FreeBSD, OpenBSD, NetBSD, etc.

Notices

Closed Thread
 
Search this Thread
Old 06-14-2005, 10:38 AM   #1
latheesan
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 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
 
Old 06-14-2005, 11:49 AM   #2
peter72
Member
 
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:

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
 
Old 06-14-2005, 12:37 PM   #3
finegan
Guru
 
Registered: Aug 2001
Location: Dublin, Ireland
Distribution: Slackware
Posts: 5,700

Rep: Reputation: 57
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
 
  


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


All times are GMT -5. The time now is 08:25 PM.

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