I Need to perform the cleanup of my one month old logs using cron schedule i take backup of all the main configuration of the server.
can you suggest which of the below command will be best for the cleanup of logs older than 30 days:
find /tapebackup/* -type d -ctime +30 -exec rm -rf {} \;
find /tapebackup/* -type f -mtime +30 -exec rm -rf {} \;
Can you help me out with the cron syntax for above cleanup.
LOG CLEANUP
Re: LOG CLEANUP
Are you looking for direction on creating crontab entries for your command or are you asking which command is preferable?
If the latter, if I understand your backup methodology, either command would work as for your backups the created timestamp and the modified timestamp would be the same.
Let us know if this answers your question.
Thank you!
If the latter, if I understand your backup methodology, either command would work as for your backups the created timestamp and the modified timestamp would be the same.
Let us know if this answers your question.
Thank you!
-
- Posts: 239
- Joined: Mon Jun 27, 2016 11:05 pm
Re: LOG CLEANUP
I think i will go with below command now can you help me out with the crontab entry :bolson wrote:Are you looking for direction on creating crontab entries for your command or are you asking which command is preferable?
If the latter, if I understand your backup methodology, either command would work as for your backups the created timestamp and the modified timestamp would be the same.
Let us know if this answers your question.
Thank you!
find /tapebackup/* -type d -ctime +30 -exec rm -rf {} \;
-
- Posts: 239
- Joined: Mon Jun 27, 2016 11:05 pm
Re: LOG CLEANUP
Once in a month any time.bolson wrote:How frequently do you want the cron job to run?
Re: LOG CLEANUP
Hello ericssonvietnam,
From the command line run the following as root:
hit the insert key and type the following:
hit the escape key and type :wq and press enter
You're good to go. May we close this topic?
From the command line run the following as root:
Code: Select all
crontab -e
Code: Select all
0 0 1 * * find /tapebackup/* -type d -ctime +30 -exec rm -rf {} \;
You're good to go. May we close this topic?
-
- Posts: 239
- Joined: Mon Jun 27, 2016 11:05 pm
Re: LOG CLEANUP
Thanks can lock thisbolson wrote:Hello ericssonvietnam,
From the command line run the following as root:
hit the insert key and type the following:Code: Select all
crontab -e
hit the escape key and type :wq and press enterCode: Select all
0 0 1 * * find /tapebackup/* -type d -ctime +30 -exec rm -rf {} \;
You're good to go. May we close this topic?