Start the service you want to happen AFTER the first one:
# systemctl start fakehalt
What "should" happen is that fakehalt will fail to find a file called /tmp/fake.test to cat from, and so everything should go horribly wrong.
What actually happens is that systemd places fakehalt service on hold until it gets an exit 0 signal from the fake service. So if you wait 21 seconds and cat /tmp/fakehalt.test, you see that the cat from a file that did not exist when fakehalt was started - actually succeeded.
Comment #1 posted on 2016-12-18 20:43:23 by CPrompt^
Great explanation of how systemd works with two services like this.
I started working with systemd services and went back to this show to get some info. Good stuff!
Just wanted to point out that in the show notes, there is a little bit of a typo.
Under the "fakehalt.service" you have listed in the Unit section :
However, right below that you call the service fake.service
You say it correct in the audio but the show notes have the typo.
Comment #2 posted on 2018-10-07 16:59:58 by david pellecchia
Many thanks for posting your information regarding systemd services. I've been pulling my hair out trying to work out why my pre-shutdown script would not fire. Then I found your post.
A very big thank you to you.
Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.
Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).