HowTo: Raspberry start command on startup with tmux

  • Posted on: 27 October 2016
  • By: robin
autostart command as specific user

What you want is to automatically start a script or programm when your raspberry pi boots. And you want so specify a user which is executing the process. Even better, you want to start it in a tmux session because this allows you to attach to the session and see whats going on. You are awesome. But you don't know how to do it ? Simply follow this simple steps:

 

1. Create a bash script file tmux_start.sh (e.g. with: touch tmux_start).

2. Add the following lines to this file (e.g. nano tmux_start.sh):

#!/bin/bash
tmux new-session -d -s peter 'python /home/pi/peter.py'

This command will create a new tmux session called "peter" and execute the command "python file.py".
Note: I used the total path.

3. Now we set up the autostart. On the raspberry pi one way is to enter a line in /etc/rc.local. Thats want we wanne do. (so: sudo nano /etc/rc.local) copy and paste this:

sudo -u pi bash /home/pi/tmux_start.sh &

This command will execute a the bash script as user 'pi'.

topic: 
tmux, raspberry pi, raspberry, pi, Rpi, autostart
Field: 

Comments

What if I want to run two py scripts?  How would I run 2 scripts in the tmux_start.sh?  Or do I run 2 tmux_start.sh files each with its own py script?  In either case, how would I make the calls?

 Content composition is very fascinating work who are in this work are truly appreciate the work. You ought to have huge learning about all the common things and subjects. The best essay writing service( https://usawriters.org/ ) discloses to us the estimation of this work for the future in light of the fact that numerous authors are getting a charge out of good life.