Last active
December 16, 2015 05:28
-
-
Save chellem/8c6a231c3e745232af41 to your computer and use it in GitHub Desktop.
Add cronjob
This file contains 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
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