wiki:Logrotate

Version 6 (modified by krit, 3 years ago) (diff)

--

Logrotate

Ref here

[root@Mosh ActDas]# more /etc/logrotate.d/actdaslog 
/tmp/ActDasLog/*.log
{
        su krit krit
        rotate 7
        daily
        size 5M      # place size after daily, it will process if file log > 5M ignore daily
        copytruncate #copy to actdas.log.1 and empty actdas.log to zero 
        missingok
        notifempty
        delaycompress
        compress
}

To run the logroate file with -f force option

[root@Mosh logrotate.d]# logrotate -f /etc/logrotate.d/actdaslog --state /tmp/logrotate-state --verbose

After run we should see

[krit@Mosh ActDasLog]$ tree /tmp/ActDasLog/
/tmp/ActDasLog/
├── mosq_feed_actDas_11_firmware.log
├── mosq_feed_actDas_11_firmware.log.1
├── mosq_feed_actDas_11_firmware.log.2.gz
├── mosq_feed_actDas_11_firmware.log.3.gz
└── mosq_feed_actDas_11_firmware.log.4.gz

0 directories, 5 files
[krit@Mosh ActDasLog]$