I'm rotating log files with logrotate
with copytruncate
, and I need to run a script with the new filename as argument. I understand I can use $1
within postrotate
, but that gives me the name of the rotated file - not the one with the date extension.
So basically I have:
/var/log/myapp/server.log
When I run this logrotate config:
/var/log/myapp/server.log {
copytruncate
rotate 1008
dateext
dateformat -%s
create 660 syslog syslog
postrotate
python3 /opt/myapp/test.py $1 > /dev/null
endscript
}
I get
/var/log/myapp/server.log <-- (now empty)
/var/log/myapp/server.log-1536844088
Can I run a script on /var/log/myapp/server.log-1536844088
in postrotate somehow?
dateformat
knowledge and have the script glob for "$1"${dateformat}