1

I have a script that imports data into custom entities created in a drupal 7 database. It needs to run daily so i've added it to my system crontab (running CentOS 6.7). The problem i am having is that when it's run from cron (the script is executable and there's a symlink to it added in /usr/sbin) it runs but fails when the drupal bootstrap is run. It works flawlessly when run from my user id, the service account user id, another persons id, and on so i know that the script is written correctly. There is no error reported to the console (grabbing std_out and std_err output in my cron command) and there are no php errors logged. I am at a loss of where to look for the answers i need to find out why it's failing. I assume it's something to do with the environment when run from cron but i've confirmed the shell is bash as expected and i'm not using any environment variables that aren't set explicitly within the script. Where can i look for more answers?

Here's My crontab:

55 16 * * * svc_load cs-import >> /var/log/import-log-`date "+\%Y.\%b.\%d"`.log 2>&1

Here's the relevant lines to load drupal from my script. I see all the echo's print out except the last "drupal loaded". I even tried an or die() after the bootstrap function but it didn't do anything, there must be a crash of some sort that aborts the script before php can process the die() function.

// Drupal Connectivity
echo "Start Loading Drupal\r\n";
define('DRUPAL_ROOT', dirname($parent_dir)."/httpdocs");
echo "Set Drupal Root\r\n";
require_once (DRUPAL_ROOT.'/includes/bootstrap.inc');
echo "Included Bootstrap.inc\r\n";
drupal_override_server_variables();
echo "Overrided Server Variables\r\n";
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
echo "Drupal Loaded\r\n";

I have PHP logging on, here's the relevant lines from php.ini but the file size never increments when I run this script (it does on other errors).

log_errors = On
log_errors_max_len = 1024
error_log = /var/www/vhosts/dev/logs/php_errors.log

Thank you in advance for any help you can provide! ~Lindsay

5
  • What Drupal version? May 20, 2016 at 14:13
  • I guess you aren't using Drupal 8, are you?
    – apaderno
    May 20, 2016 at 14:45
  • i'm using Drupal 7 May 20, 2016 at 14:48
  • Your script works perfectly for me on some sites but not others. It works better on sites that have fewer contrib modules installed, but when it fails there's always an exception for me. I see problems specifically with multiupload_filefield_widget. The only ways you could be getting to the end of this script without seeing "Drupal Loaded" are 1. Something (module/theme/whatever) is causing an explicit exit() or die() for whatever reason, or 2. It is failing with an exception, but you don't have logging switched on.
    – Clive
    May 20, 2016 at 15:31
  • @Clive I updated my question with relevant lines from php.ini, How can i track down which module it would be? May 20, 2016 at 16:00

1 Answer 1

1

I found the issue is i have multiple PHP versions installed on my system because my hosting company is running plesk. PHP 5.2 is a base version and it looks like drupal loads something that makes php5.2 fail. After upgrading my script to point to the proper 5.5 version of php everything is running as expected. Thanks to all who replied.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.