Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!class_exists('tasks')) include '/home/way_to_module/tasks.inc';
- $lock_file='/home/user/tmpdir/lockfile.name';
- if (file_exists($lock_file))
- {
- if (filemtime($lock_file)>(time()-10800)) exit;
- }
- $lock_fh=fopen($lock_file,'w');
- $starttime=time();
- $tasks=tasks::get_tasks();
- if (!empty($tasks))
- {
- $q=array();
- foreach ($tasks as $task) $q[$task->priority][]=$task;
- ksort($q);
- foreach ($q as $priority)
- {
- foreach ($priority as $task)
- {
- tasks::execute($task);
- if ((time()-$starttime)>100) break;
- }
- if ((time()-$starttime)>100) break;
- }
- }
- fclose($lock_fh);
- unlink($lock_file);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment