So I want my server to run a script which starts several tmux sessions on boot.
This is my crontab:
@reboot . /home/steven/.profile; /home/steven/Scripts/Start.sh
And this is the content of my Start.sh
#!/bin/bash cd ~/Scripts/ echo "Mounting all drives..." sudo mount -a echo "Mounting finished." echo "Starting Wemo Server..." tmux new -s "wemo" -d tmux send -t "wemo" $'./start_wemo_server.sh\n' if (tmux list-sessions | grep "wemo"); then echo "Wemo Server Ouimeaux started." else echo "Tmux error @ wemo server." fi echo "Starting GoDaddy Dynamic DNS Service..." tmux new -ds "godaddy" tmux send -t "godaddy" $'./start_godaddy_dyndns.sh\n' if (tmux list-sessions | grep "godaddy"); then echo "GoDaddy Dynamic DNS Service started." else echo "Tmux error @ GoDaddy." fi echo "Starting Plex..." sudo service plexmediaserver start echo "Plex started." echo "Starting PlexConnect Server..." tmux new -ds "plex" tmux send -t "plex" $'./start_plex_connect.sh\n' if (tmux list-sessions | grep "plex"); then echo "PlexConnect Server started." else echo "Tmux error @ Plex." fi echo "All starting sequences are finished. Quitting..."
If I start this script manually (i.e. ./Scripts/Start.sh), everything works just fine, tmux loads my profile nicely and everything is okay. However if I set the crontab to start this script, tmux doesn't load the profile, .bashrc isn't loaded, I can't even use Up Arrow key to recall previous commands, or Tab to autocomplete.
This is really rather annoying because I use tmux during the day all the time, I can't live with a broken tmux session.
Does anyone have an idea of how this can be fixed or what I've done wrong?