Scheduled execution is required in the project, but the scheduled time is a variable parameter. Instead of starting to use crontab for implementation, the time parameter cannot be customized, you also need to get a passed ID to run the sleep program and run into a problem using the sleep function in php, in s... scheduled execution is required in the project, but the scheduled time is a variable parameter, not a fixed
We started to consider using crontab for implementation, but the time parameter cannot be customized. We also need to get a passed ID to execute the program after sleep.
When using the sleep function in php, a problem occurs. parameters obtained by GET or POST before sleep cannot be obtained after sleep.
Ignore_user_abort (); // The PHP script can be executed even if the Client is disconnected (such as the browser is disabled. set_time_limit (0); // the execution time is unlimited. The default php Execution time is 30 seconds, so that the program can be executed without limit $ interval = $ _ GET ['interval']; // receive the $ _ GET parameter $ id = $ _ GET ['id']; // The id passed when the request is triggered, use flush (); sleep ($ interval); // wait for execution at the set time * // *** after sleep, use the above $ id, to execute other programs. After the test, the $ id cannot be obtained. Blank **/
Do you know anything about it? Or provide other ideas. Thank you!
Reply content:
Scheduled execution is required in the project, but the scheduled time is a variable parameter, not a fixed
We started to consider using crontab for implementation, but the time parameter cannot be customized. We also need to get a passed ID to execute the program after sleep.
When using the sleep function in php, a problem occurs. parameters obtained by GET or POST before sleep cannot be obtained after sleep.
Ignore_user_abort (); // The PHP script can be executed even if the Client is disconnected (such as the browser is disabled. set_time_limit (0); // the execution time is unlimited. The default php Execution time is 30 seconds, so that the program can be executed without limit $ interval = $ _ GET ['interval']; // receive the $ _ GET parameter $ id = $ _ GET ['id']; // The id passed when the request is triggered, use flush (); sleep ($ interval); // wait for execution at the set time * // *** after sleep, use the above $ id, to execute other programs. After the test, the $ id cannot be obtained. Blank **/
Do you know anything about it? Or provide other ideas. Thank you!
Comment out flush
Test executable
Ignore_user_abort (); // The PHP script can be executed even if the Client is disconnected (such as the browser is disabled. set_time_limit (0); // the execution time is unlimited. The default php Execution time is 30 seconds, the program can be executed without limit // params $ interval =$ _ GET ['interval']; // receive the $ _ GET parameter $ id = $ _ GET ['id']; // The id passed when the request is triggered, use flush (); sleep ($ interval); echo $ id;