You are not logged in.
Hello,
how to restart a service unit (systemctl restart unit) automatically 30sec or 1min after reboot?
I need delay actually, any idea?
Thanks in advance & have a nice day.
Last edited by user57234 (2017-10-12 20:14:50)
Offline
An XY problem?
Why do you want to do that? And what '30sec or 1min' means?
Offline
Hi,
I have done a service, my problem is always fails to start after reboot (It has to do with the networking) and I have always to remember to start it manually.
If I can add a delay like 1 min before it starts will be better (first to finish start all services for networking and then, last, my service).
Thanks
Last edited by user57234 (2017-10-11 14:09:45)
Offline
You're looking at it from the wrong angle, systemd has many things that will help you know the exact time your service needs to start, not just guess "Oh, 30 seconds has passed!"
See this wiki page here for some details on dependanies. It does depend on how you are connecting as well, for example if you're using Network Manager there is a unit you can pull in called NetworkManager-wait-online.service but since that's very system dependant I will leave it to you to research.
Offline
I'd rather suggest you use netctl profiles to connect to any network you need. I'm loving keeping it disabled at boot and launching my profile from the terminal whenever i need to connect, so i can boot as fast as arch can. Could you post output of
systemd-analyze critical-chain?
Offline
If I can add a delay like 1 min before it starts will be better
The easy way is to use a timer: see 'man systemd.timer'.
But a better way would be to go by one of the suggested ways above.
Offline
Hi, thanks for the suggestions, really interesting stuff and good ideas for further investigation. Since my service is little "heavy", I have decide to start/stop it by shell script from my application, to run it actually only when I need it. That solves my problem, because while I was working on it, I realize, that there is no point to run it on every boot.
I love systemd, endless possibilities to do magic stuff.
Thanks again,
problem solved.
Last edited by user57234 (2017-10-12 20:18:38)
Offline