Skip to content

Instantly share code, notes, and snippets.

@chellem
Last active December 16, 2015 05:28
Show Gist options
  • Save chellem/8c6a231c3e745232af41 to your computer and use it in GitHub Desktop.
Save chellem/8c6a231c3e745232af41 to your computer and use it in GitHub Desktop.
Add cronjob
private function addCronJob($jobs)
{
try {
$jobs=trim($jobs);
$filename=tempnam(sys_get_temp_dir(),'job');
if ($filename) {
file_put_contents($filename,$jobs.PHP_EOL);
}
exec("crontab {$filename}");
unlink($filename);
return true;
} catch (\Exception $e) {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment