I saw many place introduce screen
to run background job stably even log out. They use
screen -dmS name
According to screen -h
, this option means
-dmS name Start as daemon: Screen session in detached mode.
What is daemon? I don't understand.
I found that if I simply type screen
, I can enter automatically into a screen. After I run some command, and press Ctrl+a d
, and then log off. The job is still running fine. So is this simple approach OK? Do I really need -dmS
to make background job stable?
Let me try to give a summary:
Anything run in screen is safe to logging out (but you should detach the screen, not quit screen when you log out), no matter what the option you have set to screen.
-dmS
is just an option convienient for submitting jobs in background noniteractively. That is
screen -dmS nameOfScreen command
Best Answer
You would only use
-dm
if you want to run a command in a screen session and not enter it interactively-S
is just to give the session a usable name so you can reconnect to it again easily laterIf you want to use it interactively and don't want to give it a human readable name, you can omit all of those arguments safely.
For example, if you just want to start up
screen
to run the command, say,/path/to/longTime
and you don't want to watch it run you could do it either asor you could do
ctrlad
Both would accomplish the same thing, but one is both easier to script and a bit less typing.