[systemd-devel] systemctl how to stop a service

Christian Boltz systemd-devel at cboltz.de
Mon May 16 13:43:52 UTC 2016


Hello,

Am Samstag, 14. Mai 2016, 16:55:11 CEST schrieb liuxueping:
> I have a test in arm64,my test case try to start/stop a ntp service
> frequently,like that:
> 
>   #!/bin/bash
>   i=0
>   while [ 1 ];do
>   echo "========$((i++))========"
>   systemctl restart ntpd &
>   kill -9 $!

You are sending systemctl restart ntpd into the background and kill it 
the hard way. I understand you don't want to wait forever, but killing 
it instantly (while it restarts ntpd) could cause some "funny" 
behaviour. This behaviour might also be somewhat random/racy because the 
kill can happen at different states of the restart.

Can you still reproduce the issue you described if you at least add a 
"sleep 5" before killing systemctl?


Regards,

Christian Boltz
-- 
[Greylisting ist] das alte Hotline-Prinzip: Wenn der 4 Minuten lang in
der 01805 dringehangen hat, dann will er auch was von uns. Aber sofort
ans Telefon gehen? Ne!  [Peer Heinlein auf dem LinuxTag Chemnitz 2011]



More information about the systemd-devel mailing list