Re: (solved) Re: How to chain services driven by a timer?

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

 



On Thu, Apr 18, 2024 at 8:12 AM Brian Reichert <reichert@xxxxxxxxxxx> wrote:
>
> On Wed, Apr 17, 2024 at 03:03:16PM -0600, Dan Nicholson wrote:
> > I assume that this is just a script that does some post-processing on
> > log files. In that case, I suggest that you use Type=oneshot with
> > RemainAfterExit=no (the default). Then the service will actually wait
> > until your script completes. Type=simple is expected to be used for a
> > service that doesn't exit under normal conditions.
>
> Thanks for the additional feedback; I don't see the harm in trying.
>
> How, forensically, would I see the difference between 'simple' and
> 'oneshot', in my use case here?

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.
If it was Type=simple, your unit would be started before the logrotate
command completed, which is probably not what you want.




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

  Powered by Linux