cron jobs help

Status
Not open for further replies.

gonynet

Cadet
Joined
Mar 29, 2012
Messages
2
i have FreeBSD 8.2-RELEASE-p6 installed on pc, i have created a ftp server for saving videos from my ip security cameras.
now i want to create an automatic script or something else that delete old files from storage , example 10 days old.
Can some one help me
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,996
Do you know how to write bash scripts? If not I would recommend you learn about them. Understanding how commands work is not very easy if you're new to FreeBSD or Linux in general. If you can figure out how to delete a file, then figure out how to delete files beyond say 10 days, then you can place those into a simple bash script.

Try a google search for something like "freebsd delete old files" and you will fine several examples.
 

gonynet

Cadet
Joined
Mar 29, 2012
Messages
2
thank you for reply
i am new with linux, after 4-5 hour searching on google, reading, could not understand many things.could not find a step by step manual. can you help me to do this, can you learn me?
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,996
I'll give you some help but since I'm not testing it I just don't know how well it will work. You will likely have to play with it some. Be careful because it is likely to delete a lot of files and the wrong ones if you're not careful. Make sure you have a backup of your drive data before you start or test on a Virtual Machine.

Use this thread at a guide... http://forums.freebsd.org/showthread.php?t=17928

If your path to your files is "/mnt/video"

Create a CRON job, enter this as your command:

find /mnt/video -type f -mmin +10080 -delete

Run the CRON job once a day.

Actually I would run the command from a command line to verify it works. Create some files, play with the period of minutes. 10080=7days but you could use values like 2 or 5 for new files just to see if they are deleted properly.

Good Luck
-Joe
 
Status
Not open for further replies.
Top