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

Bracoau

Registered
Feb 12, 2013
3
0
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!
 

quietFinn

Well-Known Member
Feb 4, 2006
1,072
32
178
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.
 

Bracoau

Registered
Feb 12, 2013
3
0
1
cPanel Access Level
Website Owner
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.
Thanks mate!