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.

link|improve this question
feedback

3 Answers

up vote 1 down vote accepted

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

link|improve this answer
feedback

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

link|improve this answer
feedback

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
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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