Continuing Cron Jobs

Sorry if this question was asked before, however I could not find anything relevant in the search.

I currently have a PHP script that checks the database for the next record that has not been updated. My question is this: if I then update the database to show that the record is being processed during the cron job (which takes about 30 seconds), and the cron job starts every second, and in the second 1 the cron job is executed, but will Is this job waiting for completion before completing the cron job for the second time or will it run with the second 2?

thanks

0
source share
3 answers

cronjob - php script, cron script, script.

, - :

$LOCK_FN = "/tmp/my-script.lock"
if(file_exists ($LOCK_FN)){
    //previous script is not finish exit.
    die("Previous script is not finished yet.");
}
//Create lock
$fp = fopen($LOCK_FN,"w");
fclose($fp);

/*

 Put your script logic here
 */

//Open the lock work is done.
unlink($LOCK_FN)
+1

, - . , script , .

<?php
$port = 1080; // choose unused port
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if (!$sock) {
    exit;
}
socket_set_nonblock($sock);
if (!socket_bind($sock, "127.0.0.1", $port)) {
    exit;
}

while(1) { ... }
?>

script.

script Crontab * * * * *

+1

cronjob , . , , . php script

0

Source: https://habr.com/ru/post/1617536/


All Articles