Is there access to PID in linux from PHP?

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
 2788 root 15 -5 0 0 0 S 2.0 0.0 404:43.97 md3_raid1
 7961 root 20 0 2528 1684 5964 R 2.0 0.2 0:00.14 top
 6629 root 20 0 2884 8612 2096 S 0.7 0.3 0:00.96 dovecot-auth
 57 root 15 -5 0 0 0 S 0.3 0.0 4:36.10 kblockd/0
 8703 ulogd 20 0 17700 656 4216 S 0.3 0.4 87:23.98 ulogd
11336 the ldap 20 0 394M 8292 15M S 0.3 1.5 5:29.28 slapd
25757 ldap 20 0 394M 8292 15M S 0.3 1.5 5:11.71 slapd


There is a task to test a php script, the presence or absence of a particular process in the system. Is it possible to do?
Is there access from php to the command to kill the process, etc., such as kill 11336
July 12th 19 at 17:36
3 answers
July 12th 19 at 17:38
exec(), shell_exec() & co and may not be suitable?
July 12th 19 at 17:40
php.net/manual/ru/function.getmypid.php well or as already said exec() and execute ps-aux | grep "php"
July 12th 19 at 17:42
If there is a dir in /proc/.
For each running process in Linux is created in the above dir. Inside are files where a lot of interesting. Look at the contents of the directory itself - there is a wealth of information about the process.
To send signals to processes you can use posix_kill (description in the manual blaze find it yourself). If this function is not available, then use exec, system, shell_exec, etc.

Find more questions by tags LinuxPHP