How to setup cron script in drupal 7 custom script ?

 

In this article, will show you how we can setup a cron in Drupal 7 multi site.

 

define('DRUPAL_ROOT', getcwd()); // Get Drupal Root Directory //
include_once DRUPAL_ROOT . '/includes/bootstrap.inc'; // included drupal bootstrap //

// This is only for drupal running with multi site
$variables['url'] = 'SERVER_HOST'; // Server host name which your are setuping cron www.example.com/ 
$variables['SCRIPT_NAME']='/cron.php'; // script name is setup for cron //
drupal_override_server_variables($variables);
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

// Here you can call drupal functions/ Custom module/ Core module etc

db_query()
hook etc