0

I list the PID and then try to kill it using:

nohup server &
kill <PID>

However, I keep getting the error:

nohup: failed to run command ‘server’: No such file or directory

enter image description here

This is because the PID keeps changing! When I try to kill the current PID, the nohup process is suddenly another PID! Below is a screenshot of the process continually chainging PIDs.

enter image description here

AllieCat
  • 3,890
  • 10
  • 31
  • 45

2 Answers2

2

I don't think you quite understand the error message.

nohup just launches another process (in your example called server), preventing it from getting a SIGHUP once the terminal starting it disconnects.

The problem here is not that the PID changes (the displayed pid is the pid of nohup when it temporarily launches), it's that nohup can't find a command called server to launch at all.

nohup: failed to run command ‘server’: No such file or directory

Joachim Isaksson
  • 176,943
  • 25
  • 281
  • 294
  • Thanks Joachim! That makes more sense. How is the correct way to find the PID of a process I launched by calling "nohup python test.py &" – AllieCat Jul 24 '13 at 16:30
  • @AllieCat At least on linux, once you do `nohup `, you can use `$!` (`echo $!`/`kill $!`/...) in the shell to work with the pid. Normally, you'd echo it to a file so you can use it later. – Joachim Isaksson Jul 24 '13 at 16:45
1

Your process is not continually changing PIDs, you're repeatedly starting the process and it's getting a new PID each time.

nohup server &

Starts the program nohup and tells it to launch server. When nohup can't find server, it prints the error message you see and quits, hence the

Exit 127    nohup server

messages you keep seeing.

Eric Finn
  • 8,629
  • 3
  • 33
  • 42