logrotate

logrotate is a program to rotates logs. This is run daily using cronjob

/etc/cron.daily/logrotate

Logrotate config files are stored in

/etc/logrotate.d/

To rotate logs daily, add daily to the logrotate configuration. To keep logs for 5 days, add “rotate 5”.

Rotating a log

To rotate a log

/var/log/sync-servers.log

Create file

vi /etc/logrotate.d/sync-servers

with content

/var/log/sync-servers.log
{
	create 640 root adm
	missingok
	notifempty
	rotate 4
	weekly
}

logrotate nginx log by date

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *