Cron jobs in Drupal 7 I have a PHP file that does some task in consistent intervals. 

I have placed that PHP file inside a custom module folder, but I found that Drupal functions like drupal_set_message() are not available inside the PHP file. 

How do I include Drupal functions inside this PHP file?
How do I set up this php file to be run as a cron job?
You need to implement hook_cron() in your module and execute these tasks there.

Then, drupal will automatically execute these tasks during the default cron handling.

You probably have used drupal_set_message() only as an example but note that using that function in a hook_cron() implementation makes no sense because there is no user to read these messages. As an alternative, you could log messages with watchdog().