If you’re looking for something that can handle restarts automatically, and starts when the Pi starts - a service is a great solution.ġ. Maybe it’s a script that’s constantly checking for weather station data and sending it to the cloud, or a simple app that listens for requests to change a LED strip’s color. Creating A Service on your Raspberry PiĪ service is best used for an application you’d like to run continuously on your pi. If you’re looking to run something long term, continuously, with automatic restarting - you’ll want to create a service. Tmux is best used for commands that you’re running one-off, like an installation step. You can detach as described in step 4 again if you like. To re-attach to the session to check how it’s going, simply run the following # list all the sessions runningĪnd that’s it. You’ll be returned to your original session, with your long running script running in the background. Detach from the session by using the following keys: Hit “Ctrl + B” If this sounds like it fits your use case here’s how to use it.ġ. You can attach to the session and check in on it periodically and detach to let it run. As long as you don’t interrupt the pi’s power supply, your script should continue to run. If you had a one-off program that you know is going to take a long time (a make build command for instance), you can create a tmux session, run your long running command, detach from that session, and logout of the pi without worry. The tmux package allows you to create a separate shell which you can detach from and let it run in the background.
0 Comments
Leave a Reply. |