Created
March 12, 2015 08:41
-
-
Save kmgalanakis/793dfe2636f54ee8bca5 to your computer and use it in GitHub Desktop.
Run PHP cron tasks without cron available
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
ob_start(); | |
// Generage HTML page here | |
generate_full_html_page(); | |
// All magic goes here | |
$output = ob_get_clean(); | |
ignore_user_abort(true); | |
set_time_limit(0); | |
header("Connection: close"); | |
header("Content-Length: ".strlen($output)); | |
header("Content-Encoding: none"); | |
echo $output.str_repeat(' ', 10000) ."\n\n\n"; | |
flush(); | |
// Now page is sent and it safe to do all needed stuff here | |
cron_task1(); | |
cron_task2(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment