LOG CLEANUP

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
ericssonvietnam
Posts: 239
Joined: Mon Jun 27, 2016 11:05 pm

LOG CLEANUP

Post 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.
bolson

Re: LOG CLEANUP

Post 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!
ericssonvietnam
Posts: 239
Joined: Mon Jun 27, 2016 11:05 pm

Re: LOG CLEANUP

Post 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 {} \;
bolson

Re: LOG CLEANUP

Post by bolson »

How frequently do you want the cron job to run?
ericssonvietnam
Posts: 239
Joined: Mon Jun 27, 2016 11:05 pm

Re: LOG CLEANUP

Post by ericssonvietnam »

bolson wrote:How frequently do you want the cron job to run?
Once in a month any time.
bolson

Re: LOG CLEANUP

Post 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?
ericssonvietnam
Posts: 239
Joined: Mon Jun 27, 2016 11:05 pm

Re: LOG CLEANUP

Post 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
Locked