How to share variable in PHP from webpage script to script running permanently from the command line

one text

I have a script running permanently from command line on a web server. There is a loop checking new stuff in DB. To save some load I need to add a condition not to check the DB if there is no reason. When the change occurs I need immediate reaction, however it might happen that there is no change for a few hours. And yes, it is not possible to do it in the webpage_script.php :)

The idea is to use some kind or a SUPERGLOBAL variable and in webpage_script.php save TRUE to that variable and then check it in that condition in permanently_running_script_on_the_same_server.php.

However I didn't find any variable that can be used for that reason... when I try to use session_id('whateverisinhereblahblab') - to share the session, the webpage_script.php will not get loaded as the session is probably continually occupied...

webpage_script.php

$the_shared_variable['whatever'] === FALSE;
if ($something_happens){
  $the_shared_variable['whatever'] === TRUE;
}

permanently_running_script_on_the_same_server.php

while (true) {
    if($the_shared_variable['whatever'] === TRUE){



    }
}

Source