3

Suppose I have many systemd service units on ubuntu 16.04 which looks like this:

[Unit]
Description=Do something script
After=default.target

[Service]
ExecStart=/usr/local/sbin/some-script-x.sh
Type=simple
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=some-script

[Install]
WantedBy=default.target

Also I have configured rsyslog like this:

if $programname == 'some-script-x' then /var/log/some-script-x.log

Done. Service logs writes to their logs.

I want to rotate /var/log/some-script-x.log like default log files, like syslog. I have an prototype of config:

/var/log/some-script-x.log
{
        rotate 30
        daily
        missingok
        notifempty
        delaycompress
        compress
        postrotate
                invoke-rc.d rsyslog rotate > /dev/null
        endscript
}

But the system already has a file /etc/logrotate.d/rsyslog that contains the following invoke-rc.d rsyslog rotate > /dev/null.

In this configuration case there is multiple rotate calls to syslog server . It worries me. How to tell rsyslog that I want to rotate only specific service log. Or how to setup rotation properly, without extra calls?

vskubriev
  • 686
  • 9
  • 15

0 Answers0