How do you start Unix screen command with a command? How do you start Unix screen command with a command? shell shell

How do you start Unix screen command with a command?


Your program is being run (well, except the cd), it's just that it's being run without a parent shell, so as soon as it completes, it exits and you're done.

You could do:

screen -t "autotest" 2 bash -c 'cd ~/project/contactdb ; autotest'

Spawns two shells, but life will probably go on.


Try this:

$ screen -S 'tailf messages' -d -m tailf /var/log/messages

Then later you can do:

$ screen -ls1234.tailf messages

Followed by:

$screen -r 1234


This might help but may not be entirely what you want.

Put "zombie az" or "defzombie az" as the first line of your .screenrc. "az" can be whatever 2 keys you'd like. Now, when a screen ought to close (command finished executing, for instance), it won't actually close; hitting 'a' will close it, hitting 'z' will re-execute the command attached to that screen.

I found that at the screen user's manual.