Jump to content

rc.local + service problem


andy_n

Recommended Posts

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

 

 

 

 

 

 

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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)

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

 

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...

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines