How to find out is a program run with nohup or not?
19,818
You need to know pid of process you want to look at. You can use
pgrep
orjobs -l
:jobs -l [1]- 3730 Running sleep 1000 & [2]+ 3734 Running nohup sleep 1000 &
Actually, this might already tell you the answer, unless you logged off and logged in again (then
jobs -l
will not show anything).Take a look at
/proc/<pid>/fd
. Processes started withnohup
will listnohup.out
files:mvp@linux:~$ ls -l /proc/3734/fd total 0 l-wx------ 1 mvp mvp 64 Oct 29 02:32 0 -> /dev/null l-wx------ 1 mvp mvp 64 Oct 29 02:32 1 -> /home/mvp/nohup.out l-wx------ 1 mvp mvp 64 Oct 29 02:32 2 -> /home/mvp/nohup.out
and started without
nohup
will not:mvp@linux:~$ ls -l /proc/3730/fd total 0 lrwx------ 1 mvp mvp 64 Oct 29 02:28 0 -> /dev/pts/1 lrwx------ 1 mvp mvp 64 Oct 29 02:28 1 -> /dev/pts/1 lrwx------ 1 mvp mvp 64 Oct 29 02:28 2 -> /dev/pts/1
Related videos on Youtube
Author by
TheSAS
Updated on September 18, 2022Comments
-
TheSAS over 1 year
There is no difference in
ps -ef | grep sleep
output to commands:nohup sleep 60 &
sleep 60 &
In which way can I discover that program is run with
nohup
?