I'm having a heck of a time getting a tmux session to be created from a script executed by crontab. The script executes and the session is created without fail from just running it but if I run it from crontab the session isn't created and it doesn't run.

Cron command looks like:

<time> /home/Startup.sh

That script just has this one line in it.

sudo /usr/bin/tmux new-session -d -s mysession 'bash /home/pathtolaunchscript.sh'

Inside that other script is an application that just runs and does its thing.

I've made sure it's executing as the right user (in my case I'm testing as sudo) and even if I couldn't find the session I'd be able to tell if it was running anywhere by virtue of the application.

Don't really know what else to try. Other cron operations work besides this one and the scripts work outside of crontab. Thanks in advance

Edit 1: It was asked if it worked executing sleep, so I ran the following but it didn't create the session either.

sudo /usr/bin/tmux new-session -d -s mysession 'sleep 1000'

Edit 2: All paths in the scripts and in cron are complete, absolute paths.

  • Does tmux start if you have it run "sleep 1000" instead of the bash command? Commented Jul 23, 2019 at 22:23
  • I'll try that in just a moment. Thanks in advance
    – Tyler C
    Commented Jul 23, 2019 at 22:25
  • No, I get the same error @NicholasMarriott Just error connecting to tmux-0/default or no sessions error
    – Tyler C
    Commented Jul 23, 2019 at 22:35
  • Is the job running as a user that can use sudo passwordless? Commented Jul 24, 2019 at 0:59
  • 1
    lack of pty might cause this
    – asdmin
    Commented Jul 27, 2019 at 11:26


You must log in to answer this question.

Browse other questions tagged .