I have a .jar file which I run like this:java -jar server.jar 4242So I have a script java-server.sh to launch it:#!/bin/shjava -jar server.jar 4242 &server.jar should start working on system boot, so I tried:Adding @reboot /home/user/java-server.sh to crontab -eAdding bash java-server.sh || exit 1 to rc.localAdding java-server.sh to /etc/init.dNone of which work. If I log into the system and launch my script I works like clockwork until I log out. What is the problem here?
Debian Linux - run script/app on boot
debian;boot;java;startup
You should call your script will full path, for example put in /etc/rc.local: bash /usr/local/bin/java-server.sh > /tmp/java-server.log 2>&1if your script is in /usr/local/bin, of course... This will also create a log file to debug other potential problems. (Note that in production you should never create such log files in /tmp for security reasons, but in /var/log with proper permission, rettention and log rotating, but this is simplified for purposes of answer)