GianniDPC
Posts: 13
Joined: Tue Oct 11, 2016 2:56 pm

Boot script on start not working

Sat Nov 19, 2016 4:48 pm

Hello,

I have created a server in Java which I compiled to a jar file. I also created a bash script which will automatically send a command to the server and to put the received data in a query to a database.

Problem is I want the server and the bash script to start at boot so I did put it in /etc/rc.local. But that doesn't seem to work, I'm sure the server is starting because I can connect to it with a client, but it's like it crashes or something because the script doesn't send anything to my database.

When not putting these in /etc/rc.local and starting them seperately it works fine.
Attachments
BASH SCRIPT.png
BASH SCRIPT.png (25.69 KiB) Viewed 1038 times
AUTOBOOT SCRIPT.png
AUTOBOOT SCRIPT.png (11.92 KiB) Viewed 1043 times
RC LOCAL.png
RC LOCAL.png (13.66 KiB) Viewed 1045 times

Heater
Posts: 15950
Joined: Tue Jul 17, 2012 3:02 pm

Re: Boot script on start not working

Sat Nov 19, 2016 7:48 pm

The best way to get services started at boot time on modern Linux systems, like Raspbian, is to use systemd.

All you have to do is create a simple systemd "service" file in /etc/systemd/system. In there you can specify what is the program to run, what user it runs as, what directory it runs in, and so on.

Then you also have simple commands to start and stop the service manually or enable and disable it from starting at boot time.

A quick Google search for "systemd service" will find you many tutorials and examples etc.
Memory in C++ is a leaky abstraction .

Return to “General programming discussion”