I have a tmux triggering script as mentioned below, running on Raspbian Wheezy 7.10:
#!/bin/bash # this script is called "sess" tmux new-session -d -s sess1 'sudo /home/pi/bin/myscript.py' exit 0
I have checked the running script as follows :
- first by running the python script
sudo /home/pi/bin/myscript.pyand then by typing the tmux command as mentioned above
tmux new-session -d -s sess1 'sudo /home/pi/bin/myscript.py'. Both the times the script runs.
Since if a User can type and run this scripts, it is a safe assumption that the complete thing can be written as a bash script. Hence the above mentioned script 'sess'
- Step 2
I have give this file executing rights through
chmod +x /home/pi/bin/sess
- Step 3
I have also tried to run the script using
rc.local as the following:
# in the rc.local file /home/pi/bin/sess & exit 0
rc.local file gets triggered for a fact since I set WLAN parameter on boot for my Pi to join an Ad-Hoc Network.
I can clearly verify this since I can
sshinto my Pi.
Upon reboot the script is not triggered. This can be verified through the
tmux ls command which says
Connection to Server Failed. I have also verified using
sudo tmux ls incase if the superuser has the tmux session but the Output is same.
- Step 4
I tried running the script in
sudo crontab -u pi -e ## inside the crontab @reboot /home/pi/bin/sess &
I also tried creating a cron job for the superuser
sudo crontab -e @reboot /home/pi/bin/sess &
Upon reboot the script is not executed.
- Step 5
I created a sub-shell in the
rc.local to capture any activity of the script being triggered
# in the rc.local file (/home/pi/bin/sess &) > /tmp/tmux.log
upon reboot and
cat /tmp/tmux.log there is nothing inside the file. The file
tmux.log does get created though
Ironically, if do something like
sudo /etc/rc.local or
sudo ~/bin/sess while i am logged in the script gets triggered perfectly since I can actually attach the session using
sudo tmux a and also see the listing
sudo tmux ls
But since it cannot run on boot time the purpose is useless if not triggered on boot.
I have also checked the environment variables
$PATH which actually does show
/home/pi/bin in it.
I have also tried using the complete path to tmux in all my scripts since if the environment variables might not be sorted. But no Luck
$ which tmux $ /usr/bin/tmux
Ironically, If I follow such a step on my Ubuntu 14.04 LTS laptop the script gets triggered through my
Maybe try an
init.d/daemon-script but not sure if an
crontabcan't handle this then maybe a daemon also wont
I have no idea if a
~/.tmux.confis any good.