On a CentOS 6.x I created a simple service called logtraffic
which, when started, appends the output of a tcpdump
command to a log file at /var/log/logtraffic/logtraffic.log
.
I want to achieve the following regarding that log:
have that log rotated daily at midnight
keep the latest 7 logs and delete the older ones
For this, I've done the following:
- commented the following line from /etc/anacrontab
1 5 cron.daily nice run-parts /etc/cron.daily
added the following cron job:
@midnight /etc/cron.daily/logrotate
created the file
/etc/logrotate.d/logtraffic
with the content:/var/log/logtraffic/*log { daily rotate 7 create dateext missingok notifempty sharedscripts postrotate /sbin/service logtraffic restart > /dev/null 2>/dev/null || true endscript }
Looks like the log is properly truncated at midnight as the timestamps displayed in logtraffic.log prove that.
The problem is that no other older log file is present in that folder. I was expecting to have older logs with a suffix like YYYYMMDD but there are none.
What am I doing wrong?