Is there a the execution ID of the php script?

PHP script run through Cron, establishes certain record in a MySQL table the flag that they are processed (Boolean value changes via the UPDATE in case will not have time to work out before Cron will run the script again). If script execution is aborted, the record can remain locked. Is there any identifier for php to be able to record it for such records and then to check progress, or the script is interrupted?
June 3rd 19 at 20:58
3 answers
June 3rd 19 at 21:00
For example, to write the start time of the script. If the twitch script only through cron and not otherwise, it is sufficient to take the number of seconds (function time) twice in the same second script will not run. At the same time with this approach, you can implement the expiration of the locks (records locked more long than N seconds ago, be considered conditionally nonblocking)
Thank you, really, if you take the abstract time of processing of one record * the number, we get the approximate maximum time when it should be released. I will write from the end time of the write lock when setting the blocking flag. - tony_Kohler commented on June 3rd 19 at 21:03
June 3rd 19 at 21:02
The standard way not only to point out that "script running" and save the process ID of this script.
Thus, you can not only see the attribute that "the script works", and consider PID and check - is there a process in memory, and whether it is your php script.
There was a thought, but the PID is not unique, and at the time of inspection can run a completely different script with the same PID. - tony_Kohler commented on June 3rd 19 at 21:05
So the PID you can check whether the cmdline which the script is executed.
Second PID long enough rotated.
For non-critical tasks if that will start again in 10 minutes, and check (well, spinning the other script, well, he, too, will be completed before the next iteration) - tony_Kohler commented on June 3rd 19 at 21:08
Let's just say, check the PID is a standard and regular method in Linux in General for everything (look at the directory /var/run) - Jeff28 commented on June 3rd 19 at 21:11
June 3rd 19 at 21:04
In case the script is interrupted

for what reason? If errors, this is solved by using try catch. Caught an error was recorded that was a mistake, and even better was inkrementirovanie the number of errors and recorded the error text that would have handles to understand then.
Yes, mistakes will handle in try catch finally block, just a website will work on Bitrix VM at the client, there is a possibility that will be cut off and the server goes down during processing. - tony_Kohler commented on June 3rd 19 at 21:07
then only what is suggested - tony_Kohler commented on June 3rd 19 at 21:10

Find more questions by tags PHP