peppeocchi / php-cron-scheduler

PHP cron job scheduler
MIT License
808 stars 143 forks source link

Get the PID #52

Open adarmanto opened 6 years ago

adarmanto commented 6 years ago

Hello @peppeocchi.

Nice tool! Anyway, on my implementation requires to get the PID from the job execution. My approach was from http://php.net/manual/en/function.exec.php#88704.

For a while, I have forked your repo https://github.com/YucaApp/php-cron-scheduler/commit/7ad080100dbae2c9196720f1e16c54ec5ec7deb0. I'm happy to create a PR for that if you think that is good for other users to use it, or probably you have a better approach for this?

Thanks.

peppeocchi commented 6 years ago

Hi @adarmanto thanks for your comment, PRs are always welcome :) If it doesn't break any other part of the system I'd be happy to merge it!

adarmanto commented 6 years ago

Done #53 :)

saschanos commented 5 years ago

@peppeocchi, would be great if you can merge it!

adamz01h commented 1 year ago

so, in my testing the PID file the scheduler creates is its own PID $command = "($php_bin $file | tee -a $log) > /dev/null 2>&1 & echo $!"; The $! will equate to itself the spawned process will be this PID + 1, or the next available PID, at least in my local machine. I have resorted to modifying the target script to run its own PID creation file and have the it check its newly created file to see if its own PIDs line up.

adamz01h commented 1 year ago

https://github.com/adamz01h/php-cron-scheduler I have implemented using a PID written to the lock file to check running processes. If the spawned PID does not match the script that its running it will assume it died and spin up a new instance.