I'm trying to automate the creation of a tmux session and windows within it running commands and have a script to do so and although it works fine when I run it from command line, it fails if I run it from cron or from a background/nohup process.
So is there any restriction that tmux needs an interactive TTY session in order to create a tmux session/window?
More detail on what I'm trying to do in this question, although I'm really asking about the more general question of whether tmux can run 'headless' at all: tmux from cron fails "lost server"
The 'background process' I refer to is that I tried having a tmux session one window of which was running a script looping around looking for a condition and if found it ran another script to kill the tmux session then recreate it. That did the kill but not the create, possibly because the script was running inside the session that it had killed, but when I experimented with using &
for background or nohup
on the process that killed/recreated the tmux session, it succeeded the kill but the create did nothing (no error I think).
I'm not very familiar with screen
, is it likely to succeed where this fails?
Any suggestions?