问题
I have used screen to start a server process, to witch I can later attach if needed and deatach again to carry on with other things. It worked fine but I have found byobu recently and I really love it.
I want to use the same kind of scripts to run the server but instead of a screen sesson I would like to attach it to a byobu tab.
I'm using byobu-tmux (because it looks better). How could I do it?
My original scripts (they both do more, but these are the relevant parts):
# Startup
screen -a -dmS <name> <command>
# Attach
screen -x <name>
I'm using Ubuntu server 16.04
回答1:
I don't know screen
commands, so here is a quick sample commands for byobu
:
To create new tabs (called screens) inside the current session you can:
byobu new-window "ls -la && sleep 5"
To start a new session (new byobu instance you can attach to) with a command you can:
byobu new-session -s "session name" "ls -la && sleep 5"
To create it already detached:
byobu new-session -d -s "session name" "ls -la && sleep 5"
To attach to a session by name:
byobu attach -t "session name"
来源:https://stackoverflow.com/questions/38435541/script-to-start-command-in-byobu-tab