logrotate
logrotate is a program to rotates logs. This is run daily using cronjob
1 |
/etc/cron.daily/logrotate |
Logrotate config files are stored in
1 |
/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
1 |
/var/log/sync-servers.log |
Create file
1 |
vi /etc/logrotate.d/sync-servers |
with content
1 2 3 4 5 6 7 8 |
/var/log/sync-servers.log { create 640 root adm missingok notifempty rotate 4 weekly } |