Skip to content

Instantly share code, notes, and snippets.

@eimihar
Last active August 29, 2015 14:20
Show Gist options
  • Save eimihar/d5a2a8cb4a006e8952d4 to your computer and use it in GitHub Desktop.
Save eimihar/d5a2a8cb4a006e8952d4 to your computer and use it in GitHub Desktop.
Cron handling example
<?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