Planning tasks
Copy Code code as follows:
Ignore_user_abort (); User closes browser program still executes
Set_time_limit (0); Do not restrict program run time
$interval = 3; Program Cycle interval Time seconds
$link = mysql_connect (' localhost ', ' username ', ' paswd ');
mysql_select_db (' Test ');
mysql_query ("SET NAMES ' UTF8 '");
do {
User closes browser stop start
Echo str_repeat (', 4069); PHP checks the user connection status only on output. Some Web server output_buffering default values are 4096 characters. To ensure flush () is valid, set to 4069.
Ob_flush ();
Flush ();
User closes browser stop end
$query = "INSERT into ' test '. ' Test_demo ' (' title ', ' content ') VALUES (' Scheduled task ', '". Date ("Y-m-d h:i:s", Time ()). "')";
mysql_query ($query); Using the Write Database validator
Sleep ($interval);
} while (true);
If PHP is not output, the user connection status cannot be detected. Even closing the browser program runs until the Apache service is stopped or restarted.
Copy Code code as follows:
User closes browser stop start
Echo str_repeat (', 4069); PHP checks the user connection status only on output. Some Web server output_buffering default values are 4096 characters. To ensure flush () is valid, set to 4069.
Ob_flush ();
Flush ();
User closes browser stop end