jeesshnasree
Flight Engineer
Flight Engineer
  • 95 Views

How to purge more than X days logs in Linux

Jump to solution

Hello Team,

 

I am aware logs removal with find command with removal specific days.

below command removal of name_of_log older than 90 days .

find . -type f -name "name_of_log" -mtime +90 -exec rm {} \:

What is the command purge  of name_of_log older than 90 days in Linux.

 

could you please share the command for purge command.

 

similarly , please share name of the logs nullify more than 90 days .

 

I am waiting for your valuable reply.

 

regards,

jeesshansree

0 Kudos
1 Solution

Accepted Solutions
ricardodacosta
Moderator
Moderator
  • 91 Views

Re: How to purge more than X days logs in Linux

Jump to solution

You could use:

find /var/log/ -mtime +DAYS -delete 

Which I wouldn't recommend because you will be deleting those files without validating them.

To see what those files are first you can use:

find /var/log/ -mtime +DAYS -ls

But a better framework to use is logrotate which is not a daemon, but a binary called by /etc/cron.daily/logrotate.

That binary uses rotation (including retention, and purging) rules defined in /etc/logrotate.conf and /etc/logrotate.d/

 

View solution in original post

Reply
Loading...
2 Replies
ricardodacosta
Moderator
Moderator
  • 92 Views

Re: How to purge more than X days logs in Linux

Jump to solution

You could use:

find /var/log/ -mtime +DAYS -delete 

Which I wouldn't recommend because you will be deleting those files without validating them.

To see what those files are first you can use:

find /var/log/ -mtime +DAYS -ls

But a better framework to use is logrotate which is not a daemon, but a binary called by /etc/cron.daily/logrotate.

That binary uses rotation (including retention, and purging) rules defined in /etc/logrotate.conf and /etc/logrotate.d/

 

View solution in original post

Reply
Loading...
jeesshnasree
Flight Engineer
Flight Engineer
  • 84 Views

Re: How to purge more than X days logs in Linux

Jump to solution

Hello @ricardodacosta ,

 

thank you for share the command and detailed description.

 

regards,

jeesshnasree

0 Kudos
Reply
Loading...
Join the discussion
You must log in to join this conversation.