[systemd-devel] Restarting service does not work

Andrei Borzenkov arvidjaar at gmail.com
Sun Dec 21 05:52:20 PST 2014


В Sun, 21 Dec 2014 13:24:16 +0100
Cecil Westerhof <cldwesterhof at gmail.com> пишет:

> I have a service in which I log vmstat info in a H2 database. Of-course
> this is only useful when H2 is actually running. So I have the following
> service file:
> 
>     [Unit]
>     Description=Logging vmstat to H2 Database
>     Requires=h2.service
>     After=h2.service
> 
>     [Service]
>     Type=simple
>     ExecStart=/home/cecil/bin/vmstatLog.sh
>     Restart=always
>     User=cecil
> 
>     [Install]
>     WantedBy=multi-user.target
> 
> ​It works insofar that when h2 stops, vmstatLog also stops. But when h2 is
> started again, vmstatLog does not start and needs to be started manually.
> What am I doing wrong?​
> 

Nothing; this is expected behavior. Dependency in systemd is
unidirectional; you may want to change [Install] section to

WantedBy=h2.service

so that starting h2.service will also start your service.


More information about the systemd-devel mailing list