The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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`
     
  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:
    10
    Trophy Points:
    18
    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.
     
  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