Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. function mymodule_init(){
  2. //get variable content (last cron run time), if not exists, return 0
  3. $last_cron_run = variable_get('mymodule_cron_run', 0);
  4.  
  5. //if it was more than 5min before
  6. $five_minutes = 5 * 60;
  7. if($last_cron_run + $five_minutes < time()){
  8. //run cron
  9. $result = drupal_cron_run();
  10.  
  11. //do with $result what needed
  12.  
  13. //set last cron run time to variable
  14. variable_set('mymodule_cron_run', time());
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement