[systemd-devel] How to chain services driven by a timer?

Brian Reichert reichert at numachi.com
Thu Apr 11 13:17:02 UTC 2024


On Thu, Apr 11, 2024 at 11:16:36AM +0300, Andrei Borzenkov wrote:
> Show full unit definition for both logrotate.service and your service.

Sure:

10-153-68-34:~ # cat /usr/lib/systemd/system/logrotate.service
[Unit]
Description=Rotate log files
Documentation=man:logrotate(8) man:logrotate.conf(5)
ConditionACPower=true

[Service]
Type=oneshot
#ExecStart=/usr/sbin/logrotate /etc/logrotate.conf
ExecStart=/usr/sbin/logrotate -l /var/log/logrotate.log /etc/logrotate.conf
ExecStartPost=/usr/bin/logger 'XXX log rotation completed'
Nice=19
IOSchedulingClass=best-effort
IOSchedulingPriority=7
Environment=HOME=/root

10-153-68-34:~ # cat /etc/systemd/system/post-logrotate.service
[Unit]
Description=Activities after logrotation

Requires=logrotate.service

[Service]
Type=simple

ExecStart=/usr/bin/logger 'XXX post log rotation'

[Install]
WantedBy=logrotate.service

-- 
Brian Reichert				<reichert at numachi.com>
BSD admin/developer at large	


More information about the systemd-devel mailing list