sleep command using screen command is not displayed in ps
This was confusing to me initially as well. I then re-read the local screen
man page for the SYNOPSIS -- the online man page does not give a synopsis) -- and noticed that it said:
screen [ -options ] [ cmd [ args ] ]
... which led me to believe that it wanted to see the cmd
and args
as independent arguments.
Since you gave that first argument as a quoted value -- 'sleep 2m
' -- it tried to execute a command named (exactly) 'sleep 2m
', as opposed to what you really wanted, which was sleep
with its own argument of 2m
. The screen
command exited successfully (in my testing), but it did not successfully execute your command.
Use, instead:
screen -d -m sleep 2m
Instead of ps
, which will only show processes associated with the current terminal (of which the SCREEN and related processes are not), use:
ps x
which will show it:
$ ps x
PID TTY STAT TIME COMMAND
# ...
7514 pts/1 Ss 0:00 -bash
7761 ? Ss 0:00 SCREEN -d -m sleep 2m
7762 pts/2 Ss+ 0:00 sleep 2m
7880 pts/1 R+ 0:00 ps x
# ...