You are not logged in.

#1 2017-10-10 13:07:16

user57234
Member
Registered: 2017-02-06
Posts: 14

[SOLVED] Delay service to start 30sec or 1min after reboot

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

#2 2017-10-10 14:52:10

berbae
Member
From: France
Registered: 2007-02-12
Posts: 1,304

Re: [SOLVED] Delay service to start 30sec or 1min after reboot

An XY problem?
Why do you want to do that? And what '30sec or 1min' means?

Offline

#3 2017-10-11 14:08:07

user57234
Member
Registered: 2017-02-06
Posts: 14

Re: [SOLVED] Delay service to start 30sec or 1min after reboot

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

#4 2017-10-11 17:39:29

ktechmidas
Member
Registered: 2017-10-07
Posts: 5

Re: [SOLVED] Delay service to start 30sec or 1min after reboot

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

#5 2017-10-12 08:30:25

lo1
Member
Registered: 2017-09-25
Posts: 584

Re: [SOLVED] Delay service to start 30sec or 1min after reboot

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

#6 2017-10-12 13:36:03

berbae
Member
From: France
Registered: 2007-02-12
Posts: 1,304

Re: [SOLVED] Delay service to start 30sec or 1min after reboot

user57234 wrote:

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

#7 2017-10-12 20:14:18

user57234
Member
Registered: 2017-02-06
Posts: 14

Re: [SOLVED] Delay service to start 30sec or 1min after reboot

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

Board footer

Powered by FluxBB