Mail from Forum Only Sent When Cron Run Manually (and Cron Working)

Mail from Forum Only Sent When Cron Run Manually (and Cron Working)

by Bill Goffe -
Number of replies: 6
I'm running 1.6.3 under Debian. I've used Moodle for several years, but recently put it on a fresh box. When I posted to a forum I got a message out maybe 1 out of 5 times; the rest of the time no messaged went out. When I visited http://...moodle/admin/cron.php with my browser all messages went out. You'd think that I didn't have cron set up correctly, my my syslog files shows something like this every 5 minutes:
Apr 1 10:35:01 debian /USR/SBIN/CRON[15335]: (www-data) CMD ([ -f /usr/share/moodle/admin/cron.php ] && /usr/bin/php -f /usr/share/moodle/admin/cron.php > /dev/null)

I take is something is amiss, but what?

Also, where (i) do you find error logs for such problems and (ii) where is outgoing mail spooled so I can check if any is there?
Average of ratings: -
In reply to Bill Goffe

Re: Mail from Forum Only Sent When Cron Run Manually (and Cron Working)

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
try logging in as www-data and run the command manually. Does it work?

/usr/bin/php -f /usr/share/moodle/admin/cron.php
In reply to Martin Dougiamas

Re: Mail from Forum Only Sent When Cron Run Manually (and Cron Working)

by Bill Goffe -
Well, I didn't see any response in the window in which I ran this command and there was nothing in /var/log (doubtful there would be I guess). Also, I didn't receive e-mail of an overnight backup being run (which I set up) and the backup files aren't in the usual places. It would appear that www-data isn't executing the correct commands. Could be a permissions problem, but any idea of specifics?

Thanks -- this really helps narrow it down.
In reply to Bill Goffe

Re: Mail from Forum Only Sent When Cron Run Manually (and Cron Working)

by Bill Goffe -
Well, its rare to respond to your own posts, but I took at look at my /usr/share/moodle/admin directory and below is what I've got (1.6.3 on Debian). Nothing has execute permissions, but I guess that isn't needed php is just reading files, and all files are readable. My cron issue doesn't seem to be a simple permissions or ownership issue.

However, http://cook.rfe.org/moodle/admin/cron.php does work (I get messages about things it runs).

Any ideas on others things I might look at?

-rw-r--r-- 1 root root 4352 2006-05-04 01:40 admin.html
-rw-r--r-- 1 root root 4044 2006-05-04 01:40 admin.php
-rw-r--r-- 1 root root 12274 2006-07-17 22:07 auth.php
-rw-r--r-- 1 root root 4773 2006-05-04 01:40 backup.php
-rw-r--r-- 1 root root 2794 2006-05-04 01:40 block.php
-rw-r--r-- 1 root root 8617 2006-07-19 22:07 blocks.php
-rw-r--r-- 1 root root 4022 2006-05-04 01:40 calendar.html
-rw-r--r-- 1 root root 3360 2006-05-04 01:40 calendar.php
-rw-r--r-- 1 root root 6481 2006-09-10 22:31 config.php
-rw-r--r-- 1 root root 2699 2005-05-24 02:03 configure.php
-rw-r--r-- 1 root root 30573 2006-09-10 22:31 configvars.php
-rw-r--r-- 1 root root 1935 2006-06-30 08:54 courses.php
-rw-r--r-- 1 root root 3718 2006-07-18 22:07 creators.html
-rw-r--r-- 1 root root 3593 2006-05-04 01:40 creators.php
-rw-r--r-- 1 root root 13014 2006-09-10 22:31 cron.php
-rw-r--r-- 1 root root 1242 2006-05-04 01:40 dbperformance.php
-rw-r--r-- 1 root root 22462 2006-05-04 01:40 editor.html
-rw-r--r-- 1 root root 9693 2006-05-04 01:40 editor.php
-rw-r--r-- 1 root root 2821 2006-04-12 17:02 enrol_config.php
-rw-r--r-- 1 root root 3912 2006-05-04 01:40 enrol.php
-rw-r--r-- 1 root root 6748 2006-06-30 22:07 environment.php
-rw-r--r-- 1 root root 2151 2006-10-09 22:10 environment.xml
-rw-r--r-- 1 root root 3589 2006-04-12 17:02 filter.php
-rw-r--r-- 1 root root 14503 2006-07-19 22:07 filters.php
-rw-r--r-- 1 root root 3385 2006-05-04 01:40 handlevirus.php
-rw-r--r-- 1 root root 22952 2006-07-14 22:06 health.php
-rw-r--r-- 1 root root 23223 2006-12-14 04:06 index.php
-rw-r--r-- 1 root root 851 2006-05-04 01:40 innodb.php
-rw-r--r-- 1 root root 9626 2006-05-21 22:08 langdoc.php
-rw-r--r-- 1 root root 17428 2006-04-27 22:29 langimport.php
-rw-r--r-- 1 root root 27896 2006-07-09 22:09 lang.php
-rw-r--r-- 1 root root 2780 2006-05-04 01:40 maintenance.php
-rw-r--r-- 1 root root 1789 2006-07-04 22:09 misc.php
-rw-r--r-- 1 root root 2796 2006-05-04 01:40 module.php
-rw-r--r-- 1 root root 8157 2006-05-21 22:08 modules.php
-rw-r--r-- 1 root root 6058 2006-05-04 01:40 oacleanup.php
-rw-r--r-- 1 root root 1193 2006-05-04 01:40 phpinfo.php
-rwxr-xr-x 1 root root 1843 2006-05-04 01:40 process_email.php
-rw-r--r-- 1 root root 6559 2006-03-06 14:27 questiontypes.php
-rw-r--r-- 1 root root 6900 2006-05-04 01:40 register.php
-rw-r--r-- 1 root root 1835 2006-05-04 01:40 replace.php
drwxr-xr-x 5 root root 4096 2007-01-20 21:47 report
-rw-r--r-- 1 root root 866 2006-06-30 22:07 report.php
-rw-r--r-- 1 root root 6663 2006-07-19 22:07 site.html
-rw-r--r-- 1 root root 5701 2006-07-19 22:07 site.php
-rw-r--r-- 1 root root 3196 2006-07-19 22:07 stickyblocks.php
-rw-r--r-- 1 root root 4482 2006-05-04 01:40 timezoneimport.php
-rw-r--r-- 1 root root 1279 2006-05-04 01:40 timezone.php
-rw-r--r-- 1 root root 4244 2006-07-27 22:10 upgradeforumread.php
-rw-r--r-- 1 root root 5153 2006-05-04 01:40 upgradelogs.php
-rw-r--r-- 1 root root 17642 2006-05-04 01:40 uploaduser.php
-rw-r--r-- 1 root root 14825 2006-05-04 01:40 user.php
-rw-r--r-- 1 root root 1455 2006-06-30 22:07 users.php
-rw-r--r-- 1 root root 2616 2006-04-04 23:54 utfdbmigrate.html
-rw-r--r-- 1 root root 47489 2006-09-29 22:07 utfdbmigrate.php
In reply to Bill Goffe

Re: Mail from Forum Only Sent When Cron Run Manually (and Cron Working)

by Bill Goffe -
To follow up on this, there seems to be an issue with /usr/share/moodle/admin/cron.php. Here's why I think so: I put in /usr/share/moodle/admin/hello.php which is simply
<?php echo 'Hello World!'; ?>

In that directory, php -f hello.php produces the expected "Hello World." However, php -f cron.php produces nothing. Note that I also have

-rw-r--r-- 1 root 31 2007-04-13 20:38 hello.php
-rw-r--r-- 1 root 13K 2007-04-13 20:35 cron.php

But, http://website.org/moodle/admin/cron.php does execute it.

Thoughts on how I can further narrow it down? It sounds like others have this problem.
In reply to Bill Goffe

Re: Mail from Forum Only Sent When Cron Run Manually (and Cron Working)

by Ye Chen -

I have posted the same problem in other forum.

when running php -f cron.php, it produces error- database connection failed. but as all mentioned above, in the browser, it works perfectly.

Any suggestion?

In reply to Bill Goffe

Re: Mail from Forum Only Sent When Cron Run Manually (and Cron Working)

by Ye Chen -

Bill,

As I posted, php is not working for me from command line and getting error message about database connection. I don't know why.

Now if you use wget command, it will work. wget doesn't produce any output, but I do get email from forum, it means cron is running.

how to use wget, check MoodleDoc cron

hope it helps