Boot order of systemd services

In the last months I discovered the world of SystemD through two installation and configuration of ArchLinux on two different PCs, and a new product of my company that use SystemD.
At the beginning it seems very strange and difficult, but after some trys I found it very powerful!

Particurarly I discovered the simple way to manage the boot order of the system services to control some action before other (like create a dynamic folder for all the system sockets, before start the services that create that sockets).

To control your service, look for a file called “mySpecialService.service” into folder /lib/systemd/system or /etc/systemd/system.
Open that file using nano, vi or other editor and into that file search for the After parameter into [Unit] session.

Into that parameter you can insert the name of the services required to start before your service, separated by space.
Example:

[Unit]
Description=/etc/mySpecialService Compatibility
ConditionFileIsExecutable=/etc/mySpecialService
After=network.target otherService.service


You can do the same with the services that requires your action before start.

After changed these files, run the ENABLE command to configure the system with your new settings:

$ sudo systemctl enable mySpecialService.service

that is the same operation that you done with the older “update-rc.d” on SysVinit systems.

Have a good SystemD configuration! 😉

Advertisements