Results 1 to 8 of 8
hi guys i am new to coding and hope this will be easy.
I am told I need to a cron job to auto delete files stored in a folder ...
- 01-26-2009 #1Just Joined!
- Join Date
- Jan 2009
- Posts
- 3
help with cron job>
hi guys i am new to coding and hope this will be easy.
I am told I need to a cron job to auto delete files stored in a folder on my ftp.
I want the chosen folder to delete every file in the folder they are only .exe files but I need them deleted every 10 mins.
can someone show me the code I need to get this working and how to do it.
which files do i upload to the server ect...
thanks againm save my life
- 01-27-2009 #2
If you do crontab -e you can edit your crontab.
Here you can add/remove your cron jobs.
In the comment at the top you can see a template of how things are ought to look(it does at least in Ubuntu).
I have cron job that looks like this:
This will shut the system down every time you get at 11 PM.Code:00 23 * * * /sbin/shutdown -h 0
I think this should work for you:
This should run every 10 minutes, so I think you'll be okay (I'm not an expert using cron by the way, I only have that one job running).Code:00 * * * * /bin/rm [path files to be removed] 10 * * * * /bin/rm [path files to be removed] 20 * * * * /bin/rm [path files to be removed] 30 * * * * /bin/rm [path files to be removed] 40 * * * * /bin/rm [path files to be removed] 50 * * * * /bin/rm [path files to be removed]
- 01-27-2009 #3Linux Guru
- Join Date
- Oct 2007
- Location
- Tucson AZ
- Posts
- 1,939
The entry below should run your cron job every ten minutes.
*/10 * * * * /path/to/command
- 01-27-2009 #4
I think that'll work better. Just because of the fact that it's easier.
- 01-27-2009 #5Just Joined!
- Join Date
- Jan 2009
- Posts
- 3
ok so guys how would I insert this code?
the cron is on my server as cpanel and it asks for standard or advanced.
the folder i want to delete the files inside is public_html/updateserver
its so my folder wont get bogged down with to many uploads.
so whats the total code i need to copy and paste?
I have this but it just never works?
find /public_html/updateserver/ -mmin +10 -type f -exec rm {} \;
- 01-28-2009 #6Linux Guru
- Join Date
- Oct 2007
- Location
- Tucson AZ
- Posts
- 1,939
The above should work to remove all .exe files in that directory. Haven't tried it so I would suggest you put an .exe file or two in a directory, run the command from command line to test.*/10 * * * * rm -f /public_html/updateserver/*.exe
- 01-28-2009 #7Just Joined!
- Join Date
- Jan 2009
- Posts
- 3
I just wanted to say I have searched the entire internet and not one person could help it was always poor code offered or offtopic chat, but this place is greatm you got the code spot on!
so if anyone else have my issue this code works fine!
great job!
- 01-28-2009 #8Linux Guru
- Join Date
- Oct 2007
- Location
- Tucson AZ
- Posts
- 1,939
Glad it worked. Didn't have a chance to test it which is why I suggested you try on dummy files. Have fun!


Reply With Quote