Ps (Process Status) process status: lists the currently running processes
1、ps -ef |grep program name
View the running status of a program, see if a program is running, find out the process id to end the program.
The parameters of this command are explained separately below:
-e Displays all processes.
-f Full format.
2. For example, check the running state of mysql:
#ps -ef | grep mysql
(1) mysql program is not installed, the output is as follows:
root 177659 171181 0 11:32 pts/0 00:00:00 grep mysql
(2) mysql is not running, output
grep mysql
This line.
(3) Running mysql program, output content:
root 7355 7338 0 11:34 pts/0 00:00:00 grep mysql
root 14066 1 0 May17 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/data/mysql5.7 --socket=/data/mysql5.7/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql
mysql 14318 14066 0 May17 ? 13:15:09 /usr/sbin/mysqld --basedir=/usr --datadir=/data/mysql5.7 --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/data/mysql5.7/mysql.sock
The following explains the meaning of each output item (illustrated by the output of the command above):
The first column (root) indicates which user started the process.
The second column (7355, 14066, 14318) represents the id of the process
The third column (7338, 1, 14066) indicates the id of the parent process above it.
Column 4 (0, 0, 0) Percentage of resources used by CPU
The last column represents the commands and parameters for starting the process (think later
3. End the process command:
#kill process id
Force End Process Command:
#kill -9 process id