4

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?

mvp
  • 4,530
TheSAS
  • 900
  • 1
  • 6
  • 15

1 Answers1

7
  • You need to know pid of process you want to look at. You can use pgrep or jobs -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 with nohup will list nohup.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
    
mvp
  • 4,530