Re: How to chain services driven by a timer?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 11, 2024 at 4:17 PM Brian Reichert <reichert@xxxxxxxxxxx> wrote:
>
> 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
>

There are no ordering dependencies between your services, so they are
started as soon as possible. if post-rotate.service must be started
after logrotate.service, it needs

After=logrotate.service

This is also needed because otherwise the Requires directive does not
work as intended.




[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux