Webmin (Mac) to Moodle on Ubuntu to Modify cron.php

Webmin (Mac) to Moodle on Ubuntu to Modify cron.php

by Richard Weiner -
Number of replies: 4
I have Moodle 1.9.2 running on an Ubuntu based server. Logging into server via Webmin from an Apple G4 running OS X 10.5. The go to Server options in left hand column of Webmin, and then select Scheduled Cron Jobs.

See the following:

Scheduled Cron Jobs

Select all. | Invert selection. | Create a new scheduled cron job. | Create a new environment variable. | Control user access to cron jobs.

Active? Command Move
Yes /etc/cron.daily/apport
/etc/cron.daily/bsdmainutils
/etc/cron.daily/sysklogd
/etc/cron.daily/man-db
/etc/cron.daily/ntp
/etc/cron.daily/mlocate
/etc/cron.daily/0anacron
/etc/cron.daily/standard
/etc/cron.daily/logrotate
/etc/cron.daily/aptitude
/etc/cron.daily/apache2
/etc/cron.daily/apt
/etc/cron.daily/exim4-base
movegap.gifmovegap.gif
Yes /etc/cron.weekly/sysklogd
/etc/cron.weekly/popularity-contest
/etc/cron.weekly/man-db
/etc/cron.weekly/0anacron
movegap.gifmovegap.gif
Yes /etc/cron.monthly/scrollkeeper
/etc/cron.monthly/0anacron
/etc/cron.monthly/standard
movegap.gifmovegap.gif
Yes test -x /etc/init.d/anacron && /usr/sbin/invoke-rc.d anacron start >/dev/null movegap.gifmovegap.gif
Yes [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ ... movegap.gifmovegap.gif
Yes /etc/webmin/cron/tempdelete.pl movedown.gifmovegap.gif
Yes /var/www/moodle/admin/cron.php movegap.gifmoveup.gif
Select all. | Invert selection. | Create a new scheduled cron job. | Create a new environment variable. | Control user access to cron jobs.


_____________________ ************************************* __________________________

Select the last item in list (cron.php). Get to the following screen (picture below shows changes that I had already made from Simple Schedule (ALL Defaults Selected)):

Edit Cron Job

Job Details
Execute cron job as
Active? Yes No
Command
Input to command
Description
When to execute
Simple schedule .. Hourly Daily (at midnight) Weekly (on Sunday) Monthly (on the 1st) Yearly (on 1st Jan) When system boots Times and dates selected below ..
Minutes Hours Days Months Weekdays
All
Selected ..
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
All
Selected ..
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
All
Selected ..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
All
Selected ..
January February March April May June July August September October November December
All
Selected ..
Sunday Monday Tuesday Wednesday Thursday Friday Saturday
Note: Ctrl-click (or command-click on the Mac) to select and de-select minutes, hours, days and months.
Date range to execute
Run on any date
Only run from / Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec / to / Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec /
<- Return to cron list

_____________________ ************************************* __________________________

Saved Changes. Then when I return to this screen and select RUN NOW, either as root or as the administrator's Username I have provided under Moodle (have to save again with changed name), I get the following result:

Module Index
Execute Cron Job

Output from command /var/www/moodle/admin/cron.php ..

/bin/sh: /var/www/moodle/admin/cron.php: Permission denied

<- Return to cron job | Return to cron list

_____________________ ************************************* __________________________

My ubuntu server is without a monitor for the time being, as the monitor died. So, using Apple computer in office to access Moodle via Webmin. If anyone is using Webmin, and understands what is happening, could you please provide me some guidance on how to fix this?

Thoughts:

1. Do I somehow have to change permissions on cron.php in order to allow this to run? Cron works fine manually over the internet via http://path2moodle/admin/cron.php.

2. Do I need to insert some command prior to the /var/www/moodle/admin/cron.php?

Richard M. Weiner
Conservatory Prep Senior High School
Davie, Florida 33328
Average of ratings: -
In reply to Richard Weiner

Re: Webmin (Mac) to Moodle on Ubuntu to Modify cron.php

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
> Output from command /var/www/moodle/admin/cron.php ..
>
> /bin/sh: /var/www/moodle/admin/cron.php: Permission denied

I've never used webmin, so this is just a guess.

The "usual" crontab is somethig like:
*/10 * * * * /usr/bin/php /var/www/moodle/admin/cron.php > /dev/null

meaning the php command line interpreter is called from the shell to run cron.php. Your output suggests that the shell (/bin/sh) trying to execute cron.php directly which doen't make sense.

In reply to Visvanath Ratnaweera

Re: Webmin (Mac) to Moodle on Ubuntu to Modify cron.php

by Marc Grober -
webmin is a GUI front end for system admin and is a wonderful tool but in some cases necessarli provides options that are confusing to the newbee who doesn't understand what it's really doing.

By way of illustration you can look at the crontab you have created with the selections made.

Two typical issues, both of which you likely encountered, is whom to run the script as and whether you need to invoke the interpreter. If you do a web seach on "webmin cron" you will find quite a bit including urls such as this, which illustrates addressing the points raised above:
http://www.saifur-rahman.com/2008/11/how-to-set-a-cron-job-using-php-in-webmin/

additionally you have to address from moodle side whether you want to run cron.php CLI only and if running as CLI you will want to invoke interpreter (php) as you don't have access then to apache to parse the" <?php" token.

If this is over your head, read a bit
more about CLI invocation of cron.php and invoking php from cron and post your additional questions... You will have a little epiphany and then will kick yourself over how obvious answer was.... But I encourage u 2 add to cron.php docs when you have that eureka moment ;)
In reply to Marc Grober

Re: Webmin (Mac) to Moodle on Ubuntu to Modify cron.php

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi Marc

The question is, wheather my assumption the comman to be executed should look like "/path/to/php-cli /cron.php" is still a possibilty.

Can't check that from the screen shot provided, I don't see anything under "Execute as, Command, Input parameters".

OK, the OP has provided the URL to his webmin, one might be tempted to try it oneself. wink
In reply to Visvanath Ratnaweera

Re: Webmin (Mac) to Moodle on Ubuntu to Modify cron.php

by Marc Grober -
Unless something has shifted, an appropriate command line might be as you previously noted, i.e. "/usr/bin/php /var/www/moodle/admin/cron.php > /dev/null", though the user has to allow for the correct location of his php binary. And this is for the reasons discussed, i.e. cron.php is tagged for apache, which is fine when running it using wget (and there is a wealth of discussion in the forums regarding use of wget, but some of it may be misleading so readers should be discerning ;=} ) as using wget invokes cron.php through apache. However, if one wishes to use the CLI invocation, then one must provide an appropriate interpreter, in this cases php. If the shell tries to invoke it will see that the script is permed without non-executable and will bork.

That is all aside from the extraordinary range of options that webmin allows the user to confuse himself with ;=} Oftentimes webmin users will get confused over whom to run script as, and for many web apps one wants that to be as www or whatever, not as root, but that is a security matter (though the flip side is not having something run because the perms are not appropriate. In this case, adding the interpreter should resolve the problem.