简体   繁体   中英

How to run multiple screens each with a command programmatically?

I'm new to linux screen utility, and now I have to create a lot of screens, passing each some command. How to achieve that programmatically instead of creating each screen with (Ctrl+ac) and typing the command there?

Use tmux instead, tmux has a more modern API and is easy to use in most cases. To achieve you purpose with tmux , you need:

$ tmux new-session -s foo -d                # create a new session called foo
$ tmux new-window -t foo                    # create a new window
$ tmux send-keys -t foo.0 ./your_script.sh  # window number starts with 0
$ tmux new-window -t foo                    # another new window
$ tmux send-keys -t foo.1 ./another_command # another of your script
...
$ tmux attach -t foo                        # attach to your session, escape key is ^b

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM