Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function mymodule_init(){
- //get variable content (last cron run time), if not exists, return 0
- $last_cron_run = variable_get('mymodule_cron_run', 0);
- //if it was more than 5min before
- $five_minutes = 5 * 60;
- if($last_cron_run + $five_minutes < time()){
- //run cron
- $result = drupal_cron_run();
- //do with $result what needed
- //set last cron run time to variable
- variable_set('mymodule_cron_run', time());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement