Q. How do I find out my process is running? How do I get pid number for particular process?
A. The easiest way to find out is run ps aux command and grep process name. If you got output along with process name/pid, your process is running.
Task: Find out process pid
Simply use ps command as follows:
ps aux | grep {process-name}
For example find out if mysqld process (mysqld pid) is running or not:
$ ps aux | grep mysqld
Output:
mysql 28290 1.1 2.7 340496 56812 ? Sl Jul31 348:27 /usr/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --socket=/var/lib/mysql/mysql.sock
Find the process ID of a running program using pidof
pidof command finds the process id’s (pids) of the named programs. It prints those id’s on screen. This program is on some systems used in run level change scripts, especially when the system has a System-V like rc structure. In that case these scripts are located in /etc/rc?.d, where ? is the runlevel. If the system has a start-stop-daemon (8) program that should be used instead.
# pidof mysqld
Output:
28290
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop














{ 17 comments… read them below or add one }
hay man you can use pgrep also know?
why ps -aux | grep process name?
u can use pgrep like this
pgrep process name
pgrep httpd
pgrep named
pgrep firefox
etc
if any special about your command just give me info related to it
Thanks Surendra, damn good tips
you can also use this :
$>pkill -f cruisecontrol
in a cruisecontrol process which runs under java. -f does a substring search of the process string.
man, u guys rock, trust me it helps so much, when my maya hangs.
special thanks: adrian B, pkill -f maya: wow, toogood
Hi .
I have a probleam . when i start mysql it is showing MySQL manager or server PID file could not be found! [FAILED] . Starting MySQL/etc/init.d/mysql: line 159: kill: (5984) – No such process .how to solve the probleam. if any one know plz help me
Thank you very much for the info.. it works for me..
i tried using kill(pid,0) to test whether the process is existent, need to include
Aaron
when i reconfigure (squid -k reconfigure) squid i got error.
like this
squid: ERROR: Could not send signal 1 to process 6471: (3) No such process
how i can remove this error please help me.
Thanks in advance
hanks ive been searching the net on how to find the pid of a process and this post solve my problem. thank you
Bear in mind that the command itself can show up in the results. For instance:
If you only see the grep command listed, that means the named command is not running.
Hi,
I still can’t see my pid number for my postfix services. can’t find that. Help me. Thanks.
Using: Linux server 11.04
why ? mark indicating ?? while each ps -ef |grep some process
Hii,
im facing one problem with pgrep command
I want to display the PID of process with greping on process name..im using this command for that:
pgrep -lfu $UID | grep -i AddUser | grep -v grep | grep bash | tr -s ” ” | cut -d ” ” -f1
but since the path of process AddUser is too long..the output of pgrep does not shows the fullname of process instead it crops the process name and displays only first 3 chars…Any idea to avoid cropping of process name
thanku fr d infr…
hello.i want the command for taking login name as a command line argument in linux for shell program
hello, What does ps – HI do? What is the meaning of this command?
The process could be running (it has a pid) but stopped (kill -STOP $pid) (it is not actually running).