Resolved Trying to create a cron job to delete files

Discussion in 'Free Hosting' started by denizx13, May 26, 2020.

Thread Status:
Not open for further replies.
  1. denizx13

    denizx13 Member

    Messages:
    41
    Likes Received:
    0
    Trophy 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.
     
  2. lylex10h

    lylex10h Active Member

    Messages:
    982
    Likes Received:
    70
    Trophy Points:
    28
    try "rm -f /home/denizx13/domains/deniz.com/public_html/storage/cache/d_seo_module_url"
     
    • Like Like x 1
  3. garrettroyce

    garrettroyce Community Support Community Support

    Messages:
    5,345
    Likes Received:
    215
    Trophy 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
     
  4. denizx13

    denizx13 Member

    Messages:
    41
    Likes Received:
    0
    Trophy Points:
    6
    You are right i am missing the leading /. How dumb of me. Thanks a lot
     
  5. denizx13

    denizx13 Member

    Messages:
    41
    Likes Received:
    0
    Trophy Points:
    6
    that is what I am trying now. Thanks
     
Thread Status:
Not open for further replies.

Share This Page