Find the Process run by nohup command

41,911

Solution 1

ps auxwww|grep -i 'server' should return all process which has server in them. Otherwise, server may have already stopped.

You should be able to determine the PID (and store it in a file) as follows:

nohup server &
print $! >> my_server.pid

Solution 2

If a nohup.out file was created, you may run in bash:

# lsof nohup.out

it will return the pid which created/is running the file

best regards!

Solution 3

There is no definitive way to catch the exact process with the help of ps command, but you can use the following:

ps -a | grep "server"

You will get a list of all the processes running with the name "server"

Or, you can use any other keywords as well to grep the ps output.

Solution 4

The best way to launch a server in centos is with the service command.

So service httpd start

There is a chance that you want to write your program as a daemon

A daemon (or service) is a background process that is designed to run autonomously,with little or not user intervention. The Apache web server http daemon (httpd) is one such example of a daemon. It waits in the background listening on specific ports, and serves up pages or processes scripts, based on the type of request.

See http://www.netzmafia.de/skripten/unix/linux-daemon-howto.html

Share:
41,911
2vision2
Author by

2vision2

Updated on August 21, 2020

Comments

  • 2vision2
    2vision2 over 3 years

    I run a server executable in Centos using the following command "nohup server &". Now I need to kill the process "server". But I tried "ps -a" command to get the PID but I couldnt get the process. Now how to kill the "server" now?