Page 1 of 1

LOG CLEANUP

Posted: Mon Aug 21, 2017 2:57 pm
by ericssonvietnam
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.

Re: LOG CLEANUP

Posted: Mon Aug 21, 2017 3:36 pm
by bolson
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!

Re: LOG CLEANUP

Posted: Tue Aug 22, 2017 2:56 pm
by ericssonvietnam
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!
I think i will go with below command now can you help me out with the crontab entry :

find /tapebackup/* -type d -ctime +30 -exec rm -rf {} \;

Re: LOG CLEANUP

Posted: Tue Aug 22, 2017 3:02 pm
by bolson
How frequently do you want the cron job to run?

Re: LOG CLEANUP

Posted: Thu Aug 24, 2017 12:20 pm
by ericssonvietnam
bolson wrote:How frequently do you want the cron job to run?
Once in a month any time.

Re: LOG CLEANUP

Posted: Thu Aug 24, 2017 1:01 pm
by bolson
Hello ericssonvietnam,

From the command line run the following as root:

Code: Select all

crontab -e
hit the insert key and type the following:

Code: Select all

0 0 1 * * find /tapebackup/* -type d -ctime +30 -exec rm -rf {} \;
hit the escape key and type :wq and press enter

You're good to go. May we close this topic?

Re: LOG CLEANUP

Posted: Sun Aug 27, 2017 5:10 am
by ericssonvietnam
bolson wrote:Hello ericssonvietnam,

From the command line run the following as root:

Code: Select all

crontab -e
hit the insert key and type the following:

Code: Select all

0 0 1 * * find /tapebackup/* -type d -ctime +30 -exec rm -rf {} \;
hit the escape key and type :wq and press enter

You're good to go. May we close this topic?
Thanks can lock this