Remove files via cronjob?
How to remove zip files in specific folder in my hosting by cron job?
I want to remove zip files in specific folder every day at 5:00PM
My directory (files) located in:
/home/site/public_html/pics/files/
Thanks.
-
You could use the following code, but it is important that you actually understand what it does and you don't just blindly copy and paste it ....... find /home/site/public_html/pics/files/ \( -name "*.zip" \) -type f -exec rm {} +
Warning - this will also recursively loop through all the folders below the defined folder as well If you just want to limit the find to the configured folder usefind /home/site/public_html/pics/files/ -maxdepth 1 \( -name "*.zip" \) -type f -exec rm {} +
The best way of using this is to create a shell script and then call it by cron. If you don't have access to shell, you might want to explore using php to do the same thing See Cron Jobs - Version 74 Documentation - cPanel Documentation0 -
Hello @graphicsarea, I concur with @rpvw here. Let us know if you have any additional questions. Thank you. 0
Please sign in to leave a comment.
Comments
2 comments