We see the running PHP scripts with this command below on terminal:
echo 'User | ProcID | CPU | MEM | ----------------------- START | ELAPSED ---------- COMMAND'; ps aux --forest | grep php;
I would like to be email alerted when there is more than one copy of a file running at the same time. Even kill the earlier process maybe automatically!
This happens on cron jobs, when one script is stuck somehow and there comes the the next cycled run time for the cron and you have a stuck (or incomplete, slow script) continuing to run and a new instance of the same script running at the same time.
You may offer a better BASH solution (other than modifying the PHP script).
See image attached for example problem script:
\_ php -f /var/webserver/public_html/cron/scheduled_job_1.php (process id: 3824)