Skip to content

Instantly share code, notes, and snippets.

@kmgalanakis
Created March 12, 2015 08:41
Show Gist options
  • Save kmgalanakis/793dfe2636f54ee8bca5 to your computer and use it in GitHub Desktop.
Save kmgalanakis/793dfe2636f54ee8bca5 to your computer and use it in GitHub Desktop.
Run PHP cron tasks without cron available
<?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