I want to run my Java Program on my Raspberry Pi, but it needs to continue running even if i close Putty. The Program is running on my Raspberry Pi and it is starting completely fine, but as soon as I close the console the Program stops.
I can tell it stops because after closing There wont be any Logs into the log fille (except the ones from before closing the Putty Terminal)
Currently I tried it with an sh script and this line within it:
nohup java -jar /home/pi/Programms/PantaBot/PantaBot.jar > /var/log/logPantaBot.txt 2>&1 &
and with running the sh script with
sh startScript.sh&
The sh Script:
chmod 777 HandballDBFiller-1.0.0.jar
java -jar HandballDBFiller-1.0.0.jar > ~/Programme/HandballTippspiel/Log.txt
CodePudding user response:
I recommend using something like screen or tmux - they both allow you to launch "persistent" terminals that you can disconnect and reconnect to later - possibly from somewhere else, without killing processes launched from such terminals.
CodePudding user response:
You can use a program capable of detaching processes such as screen or tmux.
CodePudding user response:
Use tmux.
tmux is a terminal multiplexer. It lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal.
You can detach the current session and attach to it when connecting through ssh again.
Expect a learning curve - it takes some time to get used to it.