Last active
August 29, 2015 14:20
-
-
Save eimihar/d5a2a8cb4a006e8952d4 to your computer and use it in GitHub Desktop.
Cron handling example
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 | |
// filename : /var/www/thisfile.php | |
// cron handler | |
// let say this script is running every 1 minute, by crontab configure like : | |
// * * * * * /path/to/php /var/www/thisfile.php | |
$myTasks = array( | |
'01:20' => function() | |
{ | |
// do something | |
}, | |
'12:00' => function() | |
{ | |
// do another thing | |
} | |
); | |
$currentMinute = date('H:i'); | |
if(isset($myTasks[$currentMinute])) | |
{ | |
// Run The task. | |
$myTasks[$currentMinute](); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment