Resolved Trying to create a cron job to delete files

Status
Not open for further replies.

denizx13

Member
Messages
41
Reaction score
0
Points
6
I created a cron job to delete files every day but it is not workin.
what is the correct path ?
i put
rm home/denizx13/domains/deniz.com/public_html/storage/cache/d_seo_module_url
but it is not working.
please help.
 

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
250
Points
63
@lylex10h is correct.

Just to make it clear, you're missing the leading "/" sign, so cron thinks you're specifying a file RELATIVE to where it's at, so probably it's trying to remove /home/denizx13/home/denizx13/domains/... With the leading "/" sign, it knows you're talking about an ABSOLUTE path from the filesystem root. You also need the "-f" flag if you want it to throw caution into the wind and delete the file if at all possible.

If you pipe the output of the command to a file, you will get an error log:

Code:
rm -f /home/denizx13/domains/deniz.com/public_html/storage/cache/d_seo_module_url &2>1 >> /home/denizx13/cron_error_log.txt

If you want to delete a folder (directory) instead of a file

Code:
rm -rf /home/denizx13/domains/deniz.com/public_html/storage/cache/d_seo_module_url &2>1 >> /home/denizx13/cron_error_log.txt

These two versions create a file "cron_error_log.txt" in your home directory. The file gets longer every time so you may want to delete it every so often. Or delete it with cron, just on a longer delay :p
 
Status
Not open for further replies.
Top