[systemd-devel] failure to disable a servie from restarting

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Sun Jan 13 17:22:43 PST 2013


On Sun, Jan 13, 2013 at 04:57:54PM -0500, Paul Wouters wrote:
> On 01/12/2013 04:33 PM, Zbigniew Jędrzejewski-Szmek wrote:
> >On Fri, Jan 11, 2013 at 08:20:45PM +0100, Reindl Harald wrote:
> >>
> >>
> >>Am 11.01.2013 19:47, schrieb Paul Wouters:
> >>>So the daemon restarts all the time. So let's tell systemd to disable
> >>>it, while leaving the service running:
> >>>
> >>>[root at west ~]# systemctl disable ipsec.service
> >>>[root at west ~]# pidof pluto
> >>>1992
> >>>[root at west ~]# killall -9 pluto
> >>>[root at west ~]# pidof pluto
> >>>2095
> >>>
> >>>So I guess the man page is either lying or the disasble command is not
> >>>working as expected.
> 
> >The part that you quoted even explicitly says that 'systemctl disable'
> >has no effect on the running system!
> 
> I interpreted that as "from now on, systemd will not restart the
> service, but it will not stop the running service". So that when I
> manually killed the daemon, I expected it to _not_ start it.....
> 
> 
> >>"systemctl stop ipsec.service" is your friend NOT disable
> 
> But I don't want to _stop_ the service. I want the running service
> to not restart when/if it dies.
There's a dbus property
  readonly s Restart
exposed for units. It would serve your usecase perfectly to make it
writable. Alas.

A solution for now could be to
'sed s/Restart=yes/Restart=no/ ipsec.service > /run/systemd/systemd/ipsec.service'
and 'systemctl daemon-reload'. The changes will go away at next
reboot. (This will only work if you install files into
/usr/lib/systemd/system and not /etc/systemd/system, since the latter
once take precedence.)

Zbyszek

> >>disable controls if the service is started at boot or not
> >>and has logically no effect on a running service because
> >>"systemctl disable httpd.service" does usually not mean
> >>"stop it now", it means "start it not on the next boot"
> >>
> >>why?
> >>because you can "systemctl start" a service which is not enabled
> >>at all and if it contains "Restart=always" you normally expect
> >>it to get restartet
> >
> >Also see http://0pointer.de/blog/projects/three-levels-of-off.html .
> 
> That page does not really show me an option on how to prevent a
> restart _from now on_,
> 
> Since this still does not work:
> 
> systemctl disable ipsec.service
> systemctl stop ipsec.service
> systemctl start ipsec.service
> 
> This causes the restart behaviour to restart it again.
> 
> So my original question still is, can i temporarily disable
> Restart=always without changing the service file on disk and sending
> a system-daemon reload?
> 
> 
> Paul
> 


More information about the systemd-devel mailing list