The definition given in the man for systemd unit is a bit unclear: https://www.freedesktop.org/software/systemd/man/systemd.unit.html
If a unit
foo.servicecontains a settingBefore=bar.serviceand both units are being started,bar.service's start-up is delayed untilfoo.serviceis started up. [...]After=is the inverse ofBefore=, i.e. whileAfter=ensures that the configured unit is started after the listed unit finished starting up,Before=ensures the opposite, that the configured unit is fully started up before the listed unit is started.
Lets say I have a.service and b.service. I want a.service to start up completely before b.service because b.service depends on a.service.
After reading the aforementioned man page I couldn't find any conclusive explanation on whether:
- You only need to specify
Before=b.servicein thea.serviceunit file - You only need to specify
After=a.servicein theb.serviceunit file - You need both
After=a.servicein theb.serviceunit file andBefore=b.servicein thea.serviceunit file
Which do I need to declare dependencies for systemd unit files? Does it matter?