Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Cron Job for Deleting a files of a particular file extension.

Discussion in 'Data Protection' started by Bracoau, Feb 12, 2013.

  1. Bracoau

    Bracoau Registered

    Joined:
    Feb 12, 2013
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Hi guys,

    I'm looking for help making a cron job that can remove .tar.gz files from the default cpanel backup location (/home/user) after a specific period (say 30 days).

    I've searched google but haven't found anything that specifically does this.

    Cheers!
     
  2. Jeff Shotnik

    Jeff Shotnik Well-Known Member

    Joined:
    Oct 10, 2012
    Messages:
    61
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Denver, Colorado, United States
    cPanel Access Level:
    DataCenter Provider
    You could do `find /home/ -maxdepth 2 -type f -name "*.tar.gz" -mtime +30 |xargs rm`
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Bracoau

    Bracoau Registered

    Joined:
    Feb 12, 2013
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    thanks a lot, have set this on there now so after 30 days we'll see if it works! :)
     
  4. quietFinn

    quietFinn Well-Known Member

    Joined:
    Feb 4, 2006
    Messages:
    998
    Likes Received:
    11
    Trophy Points:
    168
    Location:
    Finland
    cPanel Access Level:
    Root Administrator
    If you are running that as a cPanel user, you only get an error message:
    find: `/home/': Permission denied

    in that case you should change it to be:
    find /home/USERNAME -type f -name "*.tar.gz" -mtime +30 |xargs rm

    where USERNAME is your cPanel username.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. Bracoau

    Bracoau Registered

    Joined:
    Feb 12, 2013
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Thanks mate!
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice