Forums | Mahara Community

Developers /
Cronjob always sending output to STDERR

anonymous profile picture
Account deleted
Posts: 2

12 October 2011, 6:21

Hi, I am currently testing mahara, looks really good!

But the first problem occured with setting up the Mahara cronjob: I have this in /etc/cron.d/mahara:

*/5   * * * * mahara php /data/webdev/mahara/lib/cron.php > /dev/null

and now I am getting Emails for each and every cronjob - this is not how it should work!

As you can see, I instructed cron to only send the standard output to /dev/null - after testing the mahara cronjob with no negative results, I see no reason, why cron should talk about his work if nothing bad happens, so I send his babbling to /dev/null.

However, if anything bad happens me (and many linux admins out there) expecting a cronscript to produce output on stderr, not on stdout - that is exactly why I do not redirect stderr to /dev/null - if something goes wrong with cron, the monitoring account should be noticed about this immediately!

But Mahara´s cronjob always sends his output to stderr - this way the wisely implemented assumptions of cron are overridden and stderr is flooded with messages about successful executions, not about errors - this is a wrong implementation of a cron script.

I looked around a little bit in mahara to find out, if there is some debug setting activated - I get cron results prefixed with [DBG] for every line, but could not find anything - I could not find enough information about Mahara´s output handling and how to configure it across different output targets like web, logfiles, shell, cron etc... any hint on this is very appreciated, could not find anything in the wiki about debugging output sent via cronjobs..., thanks!

If it is not currently possible to change the output-behaviour of the cron-script by configuration, I would suggest marking this as an error and opening a ticket - cron-scripts should talk to stderr only, if an error occured, not all the time!  

If you would like to suggest "write to logfile instead" - writing to logfiles is a completely different thing - logfiles are good for researching what happened in the past, but can not substitute immediate signaling of error occurences in systems.

BTW the wiki page on error logging suggests looking into config-dist.php for more information on how to configure Mahara logging, but there is no valuable information to be found in config-dist.php about error logging...


Thank you very much for your attention,

anonymous profile picture
Account deleted
Posts: 214

12 October 2011, 6:36

Hi Bughunter,

It looks as though you have the debug level set too high for production use.

If you take a look in lib/config-defaults.php, there's a section on logging. As I recall, the default for debug, info, and warn is LOG_TARGET_ERRORLOG.

I suspect though that in the absence of an error log being available (you're not calling this via the web server, but through directly after all), mahara is falling back to stderr.

I guess that the best option in this case would be to enable the log_file directive, and set the dbg target to LOG_TARET_FILE. I've not played with this before, but you may find that if you set the log_file directive, this happens automatically.

I suspect that the wiki needs updating - the above configuration used to be in config-dist.php, but has now moved to lib/config-defaults.php.

As a note, it's best not to edit config-defaults directly but to copy any requried settings to your config.php.


anonymous profile picture
Account deleted
Posts: 2

12 October 2011, 16:44

Hi Andrew,

thanks for your reply - I did not yet change the default settings regarding logging in my first test install - unfortunately setting a logfile does not seem to change the cron-script talking too much to stderr. I set  the $cfg->log_file variable to a file mahara can write to, but still the cron-script sends messages to stderr, looking like this:

[DBG] 10 (lib/cron.php:45) ---------- cron running Wed, 12 Oct 2011 21:00:02 +0200 ----------
[DBG] 10 (lib/cron.php:90) Running PluginBlocktypeExternalfeed::refresh_feeds
[DBG] 10 (lib/cron.php:90) Running PluginInteractionForum::interaction_forum_new_post
[DBG] 10 (lib/cron.php:146) Running core cron activity_process_queue
[DBG] 10 (lib/cron.php:146) Running core cron import_process_queue
[DBG] 10 (lib/cron.php:146) Running core cron rebuild_artefact_parent_cache_dirty
[DBG] 10 (lib/cron.php:168) ---------- cron finished Wed, 12 Oct 2011 21:00:02 +0200 ----------

How can I disable logging conmpletely? This is not a final solution, but I need the cron-script to shut-up...

Thanks again for your attention!


François Marier's profile picture
Posts: 411

12 October 2011, 17:42

Hi Bughunter,

I've updated the wiki to point to htdocs/lib/config-defaults.php since that's the correct file as Andrew pointed out.

Other than that, I think you're right, the logging settings seem to be mostly ignored by cron. Would you like to file a bug for this on the tracker so that we can try to fix it for Mahara 1.5?

If you want to redirect all logging output (including from cron) to a file, put something like this in your config.php:

  $cfg->log_dbg_targets = LOG_TARGET_FILE;
  $cfg->log_info_targets = LOG_TARGET_FILE;
  $cfg->log_warn_targets = LOG_TARGET_FILE;
  $cfg->log_environ_targets = LOG_TARGET_FILE;
  $cfg->log_file = '/tmp/mahara.log';



anonymous profile picture
Account deleted
Posts: 808

12 October 2011, 17:53


$cfg->log_dbg_targets = 0;

into config.php should do the trick.

5 results