andy_n Posted December 26, 2018 Posted December 26, 2018 Hi I'm trying to start own service with rc.local automatically on the boot: sudo systemctl start Announce.service I can successful start it manually from terminal (/etc/rc.local) but it is not starting automatically on the boot. rc.local ist starting ([ OK ] Started /etc/rc.local Compatibility new / new is from me) I didn't find any solution by google. Thanks Andy
guidol Posted December 26, 2018 Posted December 26, 2018 on a real PC with debian stretch I got the problem of the missing rc.local With instrustions I did rebuild this as a service, but the service was starting too fast - so I had to put a sleep 20 as the first command in beginning of the rc.local Maybe your service will also start with pause of 20 seconds? Could be a chance because you did wrote it will start successfully when started from commandline. #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. sleep 20 systemctl start Announce.service exit 0 1
andy_n Posted December 26, 2018 Author Posted December 26, 2018 Thanks guidol, It's really working! I would never thought it. I spent the last 2 weeks fighting with the boot time (important for me) and now I suddenly lose 10 seconds. Works with 5 s, but I do not like timers on the edge. I do not like to wait, no matter where. There is no another (elegant) solution? When booting, Linux should send short UDP broadcast datagram. It's all. Thanks guidol again. It was helpful.
guidol Posted December 27, 2018 Posted December 27, 2018 the next chance would be an crontab-entry for reboot - maybe thats the right moment to start your service? # Edit this file to introduce tasks to be run by cron. # m h dom mon dow command @reboot systemctl start Announce.service if it doenst start - try to put your command line in a shell-script (.sh)
guidol Posted December 27, 2018 Posted December 27, 2018 11 hours ago, andy_n said: There is no another (elegant) solution? When booting, Linux should send short UDP broadcast datagram. It's all. more elegant would be to know the right moment - when to start- your service and on what it depends. if your service depends (because of the UDP packet = a full working network) then the following page could have an solution for you: Systemd: how to make a systemd service start after network fully connected? Also have a look at How to list all services that start AFTER certain service in systemd 1
andy_n Posted December 28, 2018 Author Posted December 28, 2018 guidol! It is working absolutely perfect. In most programming forums you get arrogantly stupid answers (guys who just want to satisfy quote, who has more answers today). Here you get the right help. Thank you. Andy 1
guidol Posted December 28, 2018 Posted December 28, 2018 5 minutes ago, andy_n said: It is working absolutely perfect. In most programming forums you get arrogantly stupid answers (guys who just want to satisfy quote, who has more answers today). Here you get the right help. Thank you. No problem maybe you can help in the future anyone who needs a right answer here in the forum... Mostly you need only the right search-keywords for the aunt Google and in the future I have the solution for me also!
andy_n Posted December 28, 2018 Author Posted December 28, 2018 Sure, if I can help. I'm a beginner in Linux but have a lot of experience with uC programming. I'm always looking for aunt google before I 'engage' forum. But for beginner, the biggest problem is: how do I ask the question?! I'm always saying my friends: I can not program, but I can google. Thank again... 1
sfx2000 Posted December 29, 2018 Posted December 29, 2018 On 12/26/2018 at 11:18 AM, andy_n said: I'm trying to start own service with rc.local automatically on the boot: sudo systemctl start Announce.service I can successful start it manually from terminal (/etc/rc.local) but it is not starting automatically on the boot. rc.local ist starting ([ OK ] Started /etc/rc.local Compatibility new / new is from me) Hint... rc.local is driven from sysv init... and systemd has the compat layer, but it doesn't always work. systemd needs the unit file to be created, and systemd will launch it...
andy_n Posted December 29, 2018 Author Posted December 29, 2018 Hi sfx2000, Another possibility, thanks. I will check it. Did you mean: systemd doesn't always work?
Recommended Posts