0

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+a c) and typing the command there?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
  • Why do you want to do that? – Will Jul 01 '15 at 08:21
  • because I 'm parallelizing some process on multi core machine, so each screen will run a command with specific parameter that is changed with each screen. –  Jul 01 '15 at 08:23
  • Why not use `nohup` or just run your jobs in the background with `&` ? – Will Jul 01 '15 at 08:26

1 Answers1

0

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
ospider
  • 9,334
  • 3
  • 46
  • 46