When I ran my cron manually ,everything is working fine.But when it run automatically it is generating the error message.

This is my code in my cron.

function hook_cron() {

function mymodule_report() {
  $user = variable_get("Username",NULL);
  $password = variable_get("Password",NULL);

  if(strlen($user) >0 && strlen($password) > 0) {
  else {
    watchdog(watchdog_id, 'Not running my cron as not all credentials have  been specified', NULL, $severity = WATCHDOG_WARNING);


In my settings.php

$conf['Username'] = "my name"
$conf['Password'] = "my password"

Well if I run cron manually,it takes the username and password variables and executes my_function.

But when cron run automatically ,username and password will take NULL values and generating the warning from watchdog "Not running my cron as not all credentials have been specified"

Is it not taking global variables when running automatically,i am totally confused on this Please help

  • check your variable table, if the value for Username and Password is set. – shrish Jun 25 '14 at 5:37
  • Hi @shrish ,thanks very much for the response.I am writing it these variables to database instead setting it as global variables in settings.php ,drupal bootstrap will take care of these variables right??? – Vishnu Jun 25 '14 at 8:50
  • Yes it does save the values to variable table, just make sure if the values are set properly. – shrish Jun 25 '14 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.