1

I have a bash script that starts a tmux session with some monitoring tools, and have a cronjob that runs it on startup; however, I can't see the usual prefix to my commands, and I can't use any arrow keys.

enter image description here

Normally it should look like this:

enter image description here

(the actual script)

#!/bin/sh

cd /home/ubuntu/

tmux start-server

tmux new-session -d -s "0" bash
tmux selectp -t 1
tmux splitw -h -p 50
tmux selectp -t 2
tmux splitw -v -p 50
tmux selectp -t 3
tmux send-keys "htop" C-m

# Select pane 1
tmux selectp -t 0
tmux attach-session -t "0"
tmux detach

What went wrong??

0

It looks like you cron job started sh or dash instead of bash (Ubuntu made a difference between bash and sh... I don't know if it is still the case). You should be able to check this with a ps ux when your cron-tmux is running.

If a real bash was started, maybe it didn't source ~/.bashrc: try /bin/bash -i, or manually source it in your script.

Also, within a cron job, the environment is usually minimal. Type env in your tmux session to see what is available, this could give you a clue.

If your cron is run as root (you didn't mention, so I assumed as user), his bashrc may be minimal or inexistant, hence the ugly cmdline.

  • 1
    The OP says that Ctrl-C doesn't work, which is a function of the tty driver, not of the shell. Something else is going on there. – pizdelect Dec 29 '18 at 16:12
  • @pizdelect My mistake, Ctrl-C does work, just the arrow keys don't – Cherona Dec 29 '18 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.