How to set cron jobs in Drupal 7?

I have a PHP file that does some task in consistent intervals and I have placed that PHP file inside a custom module folder but function like drupal_set_message() are not available inside that file. How do I include Drupal functions iside this PHP file and how can I set up this php file to be run as a cron job?

Micheal Walker Asked on October 21, 2015 in Drupal.
Add Comment
1 Answer(s)
Best answer

You will need to implement the hook_cron() function in your module and execute these tasks there. You can read more about hook_cron() function from the following link:

After this function is implemented, your drupal will automatically execute these tasks during the default cron handling.

Gregory Specter Answered on October 21, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.