User Tools

Site Tools


adding_custom_php_to_drupal_chron_directory

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
adding_custom_php_to_drupal_chron_directory [2017/08/18 08:57] tomgleadding_custom_php_to_drupal_chron_directory [2017/08/18 09:09] (current) tomgle
Line 2: Line 2:
  
  
-10 +From Stackoverflow:\\
-down vote+
 If you need to run code just once, you can do it without installing any module, including the Devel module. If you need to run code just once, you can do it without installing any module, including the Devel module.
  
 Write a PHP file (e.g. tasks.php), put it where the cron.php file that comes with Drupal is, and add the following code. Write a PHP file (e.g. tasks.php), put it where the cron.php file that comes with Drupal is, and add the following code.
  
 +<code>
   /**   /**
    * Root directory of Drupal installation.    * Root directory of Drupal installation.
    */    */
   define('DRUPAL_ROOT', getcwd());   define('DRUPAL_ROOT', getcwd());
 +  
   include_once DRUPAL_ROOT . '/includes/bootstrap.inc';   include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
   drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);   drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
   drupal_set_time_limit(240);    drupal_set_time_limit(240); 
-  // Your code here. 
      
 +  // Your code here.
 +</code>
 +
 If you are already using Drush for maintaining/deploying your site, then you could make a Drush script. In this way, it could be executed by CLI, and it could receive any arguments, making it re-usable for many occasions. If you are already using Drush for maintaining/deploying your site, then you could make a Drush script. In this way, it could be executed by CLI, and it could receive any arguments, making it re-usable for many occasions.
 <code> <code>
adding_custom_php_to_drupal_chron_directory.1503061071.txt.gz · Last modified: 2017/08/18 08:57 by tomgle