I have a php script that perform some actions after killing some old processes.
act.php
$pids = shell_exec('ps aux | grep "saso" | awk '{print $2}'');
$pids = str_replace("n", ' ', $pids);
$pids = array_filter(explode(' ', $pids));
foreach ($pids as $pid) {
shell_exec('kill -9 ' . $pid . ' > /dev/null 2>&1 &');
}
// reset of the code . ..
The script works well by running php act.php
. It fetch process ids, kill it, then run the reset.
But it is not working when I run nohup php act.php &
or nohup php act.php
. The process is not killed.
I need nohup
to run the script in the background with no hang up.
Can’t PHP script fetch pids behind nohup
? and are there any alternatives ?
Thanks in advance.