I'm trying to setup a cron job in cPanel to empty a cache directory every day at 3am. Doesn't seem to be working - what am I doing wrong?
Well, if you just run 'rm' it will prompt you if you want to delete file by file and since it is automated, it will most probably get stuck at that stage. You can do a brute force no prompt deletion using rm -rf /home/whatever/public_html/cache/* The -rf will skip the prompt and delete everything which can be deleted in that folder. So make sure it is correct or else you find yourself losing not just those undesirable files but everything else too.
Hi, thank you, this looks to be 100% good command, but when i added it to my Crontab module in cPanel (shared hosting), it does not delete files in that folder: Please can anyone help me? Please There is no root folder like /home/myusername/ in shared hosting FTP...
If you have shared hosting, then you probably don't have permissions to remove those files/folders. If you have root access to the server, then type the following command (not recommended): chown username:username /mail/new/* With shared hosting, you will only be able to delete files/folder within your home directory. (/home/username) Hope that helps.
Thank you, i have reseller hosting and this is an shared account. I have not SSH root access. This is my main reseller FTP account on the most up level: is it ok?
You must have root access to the server for the command you want to run. If you explain what you want to do in more detail, maybe we can help you further. (please post a new thread, not on this old one)
Hi, normaly server people create alias of usual commands like rm, vi so to delete from real rm command use: 'rm' -rf /home/whatever/public_html/cache/* dont miss the single quotes of rm they are required to call original rm command not the alias i hope this helps
I believe cache would have had 777 permission you could delete it, but mail folder will never have such permission rather more strict that only owner Or root user could fire it. I dont think your crontab with your user rights has permission to delete files from that folder (rather even can't view it). The user who has right to modify that folder can add this cronjob in his crontab can you (with user rights) modify it, if yes then ask your hosting provider to help as of why your cronjob is showing permission issue. i hope my english is good enough for you to understand.
I can even delete that folder or change its permissions. Maybe you are right it canwork when i change permissions to 777, not sure, but my hosting provider told me i canot delete files directly usng cron, maybe the simply disbled rm command and such for shared hosting. But anyway i have found where was the problem, i had wrong command in my Cronjob so it flooded that folder by error and successful cronjob messges. http://forums.digitalpoint.com/showthread.php?t=1906220#post14774756
If they change the rm, this would probably disable the deletion from your file manager as well. rm is a basic command, I do not suppose they would intentionally disable this for any user. Try this on your cronjobs and you should find the truth!
I'm using: rm -f /folder/* (This is only the short version, I do use the full location) It won't work. When I try the command in puTTy it works perfectly.