Knowledgebase

Portal Home > Knowledgebase > Articles Database > Shell Command to remove older files


Shell Command to remove older files




Posted by xs-admin, 07-08-2012, 03:52 AM
Hello Guys, I am making backups of a client's website on a remote FTP location. I have a script (usable without root access on cPanel) which is making backups on given cron and transfer it to remote ftp location. Now the real problem is starting; as we can't have unlimited gigabytes of disk space on any server so we have to limit the backups. I was finding shell command (which can be added to cronjob directly or by creating a bash script and call that script from cron. I want to keep 1 week's daily backups. I want to delete any backup from that directory which is older than 1 week. I found following command which looks promising But when I ran this command (for testing I replaced 'rm' with 'ls -l') I got following error can anybody help to resolve this little issue? I am running CentOS + cPanel Thank You

Posted by RoseHosting, 07-08-2012, 04:06 AM
You must place a space between the {} and the \;

Posted by xs-admin, 07-08-2012, 04:10 AM
Great. Thanks buddy. ----- EDIT ----- It's not locating the backup files. Only found .htaccess which I am using with .passwd. What changes it require to find following 2 types of backups and remove them without touching .htaccess Last edited by xs-admin; 07-08-2012 at 04:17 AM.

Posted by foobic, 07-08-2012, 06:39 AM
You may not need the maxdepth but it can be useful to stop find going chasing off down subdirectories.

Posted by RRWH, 07-13-2012, 08:52 AM
I don't bother to remember the syntax - I just head to http://find.unixpin.com/ fill in the options I need and then copy the whole command I need.

Posted by kevincheri, 07-18-2012, 10:34 AM
nice URL to test our knowledge itself

Posted by JohnCrowley, 07-18-2012, 11:56 AM
Probably the coolest link I'll see all week. Thanks for the tip!



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Urdpad.net (Views: 584)


Language:

Contact us