The usual way of dealing with this problem is a PID file. Write the cron job's process ID to a file in a known location when the job starts and delete the file when the job ends. If you need to kill the process before it ends, just read the PID out of the file and kill the process. You'll want to include some signal handling in the cron jobs so that they properly clean up their PID files though, you wouldn't want to send a SIGTERM to the wrong process just because someone left a stale PID file around.
I need to provide my users with a way to stop their cron task so that it can restart on its 5 minute cycle.
I think I need to use
shell_exec to get the processes back and then kill the specific process. The only way I will be able to distinguish this process from the others running on the server are the paths i.e
Does anyone know a way I can get the process ID of a process by matching the path?