[systemd-devel] (solved) Re: How to chain services driven by a timer?
Brian Reichert
reichert at numachi.com
Thu Apr 18 15:48:38 UTC 2024
On Thu, Apr 18, 2024 at 09:23:29AM -0600, Dan Nicholson wrote:
> Since you likely don't have any units that depend on your service it
> likely doesn't make a big difference. To demonstrate, here's a stupid
> service I created:
>
> # cat /etc/systemd/system/foo.service
> [Service]
> Type=oneshot
> ExecStart=/bin/echo foo
>
> With Type=oneshot, the journal output looks like this:
>
> Apr 17 15:02:50 endless systemd[1]: Starting foo.service...
> Apr 17 15:02:50 endless echo[5390]: foo
> Apr 17 15:02:50 endless systemd[1]: foo.service: Deactivated successfully.
> Apr 17 15:02:50 endless systemd[1]: Finished foo.service.
>
> With Type=simple, the journal output looks like this:
>
> Apr 17 14:55:23 endless systemd[1]: Started foo.service.
> Apr 17 14:55:23 endless echo[4482]: foo
> Apr 17 14:55:23 endless systemd[1]: foo.service: Deactivated successfully.
>
> Notice that in the oneshot case it doesn't reach Finished until after
> Deactivated. In the simple case, it immediately goes into Started. If
> I had a unit with After=foo.service, it would be started before
> foo.service actually did anything if it had Type=simple.
>
> Of more interest to you is logrotate.service, which is Type=oneshot.
(Confirmed, it is.)
> If it was Type=simple, your unit would be started before the logrotate
> command completed, which is probably not what you want.
Thanks for all of the succint details! I'm incorporating your advice.
--
Brian Reichert <reichert at numachi.com>
BSD admin/developer at large
More information about the systemd-devel
mailing list