News How To Run Long-running Scripts on a Raspberry Pi

Feb 26, 2022
1
0
10
If you're using tmux and you only have one session, it's far easier to reconnect with tmux attach-session

But by far the easiest method of running a script without it being terminated when you disconnect from SSH is using nohup
 

1_rick

Distinguished
Mar 7, 2014
104
44
18,620
Unless it isn't on the Pi for some reason, if you have a long-running script that you don't necessarily need to connect back to you can always nohup it.
 
Feb 27, 2022
1
0
10
Great tutorial! Tmux is a great tool for running one-off, long running scripts. I'm also a big fan of supervisor.
 
Feb 28, 2022
1
0
10
I tried the tutorial but I get an error message when I enter

pi@raspberrypi:~ $ sudo systemctl start myscript && sudo systemctl enable myscript


Failed to start myscript.service: Unit myscript.service has a bad unit file setting.
See system logs and 'systemctl status myscript.service' for details.


I named my script my_script.py and copied and pasted from the website so there should be no spelling or syntax errors