How to Add Delay to systemd During Booting
What we are trying to achieve is rather simple. Let’s say the setup service2
relies on service1
— it needs to be started after the first service is up and running. Run the following command to edit a .service file for systemd:
sudo systemctl edit [service2]
Once the editor opens, there are two ways to tackle the problem, either specify prerequisite for the service, or simply add some delay. I would suggest using both for maintenance purposes:
[Unit]
Requires={your.service1.service}
After={your.service1.service}
[Service]
ExecStartPre=/bin/sleep {time}
To avoid confusions, I’ve used curly brackets for variables in this one. Please be mindful to update and only update the ones inside the {}
brackets. {time}
takes time in seconds.