2

I'm using screen (LINUX) to run servers or task, but I want to put more than one task in one screen, is it impossible? Like:

screen -A -m -d -S test_screen userdel -r user_test && useradd -m -p 'encrypt_pass' user_test

How to change && because it leads first task left in screen and another execute in display and "" doesn't help, too.

I want to do it that each task executes one after the other.

3 Answers 3

1

Try this screen -A -m -d -S test_screen sh -c "userdel -r user_test && useradd -m -p 'encrypt_pass' user_test"

Encasing the command in sh -c "" runs the whole command in the default shell

0

Put all commands you want to execute into a shell script and run it with screen.

0

Several ideas:

  1. Put the commands in a script, run the script from within the screen.
  2. Use subshell (i.e. put the commands inside ( ) )
  3. Use bash -c 'command a && command b' as the command to be run by screen

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .