|
Hi I'm surprised that the Bitnami Moodle image (ubuntu) when set up and running doesn't appear to have the moodle/htdocs/admin/cli/cron.php running automatically. I had a warning message from Moodle stating that cron had not be excuted for a long time, so I ran it manually from the command line. Am I missing something here? What should I do? Should I create my own with crontab. Is there any documentation on this? Thanks /Jason |
|
Hi, I created a quick guide to install it in the machine, I hope it helps. http://wiki.bitnami.org/Applications/BitNami_Moodle#How_to_install_cron_task_for_Moodle.3f Hi Beltran, I'm setting up Moodle 2.3 on Amazon EC2 and having the same difficulty setting up cron. I'm doing it from the Bitnami console through Amazon EC2. After running "/5 * * * su daemon -c '/opt/bitnami/php/bin/php /opt/bitnami/apps/moodle/htdocs/admin/cli/cron.php >/dev/null" (I'm trying to run cron every 5 minutes). I get the error: "E486 Pattern Not found: 5* su daemon -c" Can I manually add the task to cron.php? If so, how can I do this? Or is there something else I can do? Thank you.
(24 Jul '12, 10:34)
deverezieaux
sorry, this is not a command. When your run the "crontab -e" command you should be able to edit a file. You only need to add this line on that file.
(24 Jul '12, 14:16)
Beltran Rueda ♦♦
I was able to determine I had skipped a step of saving the crontab. Pressing "i" to insert the text, "Esc" and entering ":wp!" to save seemed to work. I saved: "/5 * * * su daemon -c '/opt/bitnami/php/bin/php /opt/bitnami/apps/moodle/htdocs/admin/cli/cron.php >/dev/null" to run cron every 5 minutes. However it doesn't appear to be running. The Moodle notifications tab indicates that cron still hasn't been run for 24 hours. Any advice you could offer would be incredibly helpful. This is the last step for our instance.
(25 Jul '12, 00:19)
deverezieaux
try to redirect the output to a file instead of /dev/null, for example >/tmp/log.txt and check if this file was created. Note that you have to run the "crontab -e" command with sudo to create this task in the root crontab: $ sudo crontab -e
(25 Jul '12, 13:23)
Beltran Rueda ♦♦
I placed the task in the root crontab using "sudo crontab -e" and let it run for a while, but unfortunately this produced no log.txt in /tmp. I also tried placing it under bitnami using just "crontab -e" and let it run, but this also produced no log.txt. I'm currently running cron as a task from a separate Windows machine, but this is obviously not an ideal, long-term solution. Is it possible that the structure for " '/opt/bitnami/php/bin/php" is incorrect? I ran into this issue when looking for php.ini earlier in the installation. the file "/opt/bitnami/php/" doesn't exist.
(26 Jul '12, 12:36)
deverezieaux
It is strange, are you using the BitNami Moodle Amazon image right? In this case /opt/bitnami/php folder should exist.
(27 Jul '12, 06:13)
Beltran Rueda ♦♦
I am using the Bitnami Moodle AMI. In another posting of mine on these forums, Kaysa pointed out the following in regard to directory structure: "Notice that our RedHat images use the system php. In /opt/bitnami/properties.ini you can find information about the components used. For php you will see an entry like this: [PHP] php_binary_directory=/usr/bin php_configuration_directory=/etc This means that php.ini is located in /etc/php.ini." If I'm not mistaken this would also affect the location of "/opt/bitnami/php/bin/php" Pardon the delayed response from me, I missed your response.
(30 Jul '12, 10:25)
deverezieaux
Hi, you should try using /usr/bin/php instead. Also if it still fails try to execute as root user: su daemon -c '/opt/bitnami/php/bin/php /opt/bitnami/apps/moodle/htdocs/admin/cli/cron.php Also check in the properties.ini if the apache user is daemon or anything else. In some systems it runs as nobody.
(30 Jul '12, 13:22)
kaysa ♦♦
Hi Kaysa, The user is actually listed as a "apache". I also noticed that there is no /usr/bin/php directory, only /usr/bin/ not sure why that is. I haven't changed the directory structure at all. I'll try running the commands you suggest. Thank you!
(30 Jul '12, 15:40)
deverezieaux
Unfortunately neither of these suggested changes worked. I tried running them both as "daemon" and "apache". I conducted a search for the PHP file and it is in usr/bin/.
(30 Jul '12, 16:57)
deverezieaux
Here's what I've tried: "/5 * * * su daemon -c '/usr/bin/php /opt/bitnami/apps/moodle/htdocs/admin/cli/cron.php >/tmp/log.txt" using both sudo crontab -e and crontab -e. Also tried "apache" and "bitnami" instead of daemon. PHP is owned by root, cron.php is owned by bitnami, but properties.ini says apache is run by user "apache". Running "sudo php /opt/bitnami/apps/moodle/htdocs/admin/cli/cron.php" from the command line worked. I received this error: "!!! Detected incorrect $CFG->wwwroot in config.php, it must not contain trailing slash." I changed wwwroot temporarily to run this.
(30 Jul '12, 20:39)
deverezieaux
The cron job is now running successfully as: "/5 * * * sudo php /opt/bitnami/apps/moodle/htdocs/admin/cli/cron.php >/dev/null" I'm sure this is not the best way to write this job, but it works. In order to make this work I had to change /moodle/htdocs/config.php. I had to change wwwroot to the URL of my EC2 instance. It had to be the EC2 URL, not my domain name, or the site became unreachable. I tried running it beginning with "su daemon", "su apache" and "su bitnami". When I did this the log.txt file indicated "The user is not available." Is there a better way to write this job?
(30 Jul '12, 22:31)
deverezieaux
Hi; it's been a couple weeks and I'm wondering if anyone has come up with the correct coding for this task? I've shared my solution on the Moodle forums and as I thought they advised against the reference to PHP, but they aren't sure what the correct path should be in the Bitnami image.
(13 Aug '12, 14:08)
deverezieaux
Your solution seems ok. Which user is running the cron task? Notice that the users allowed to run that task depends on the permissions of the cron.php (and other related files) and php binary. If the apache user has access to the php binary another solution could be just create that tasks for the apache user (and don't use 'su' in the definition of the task). Regarding changing the config.php to use the IP instead of using the domain, it is likely that from inside the machine the domain name is not found. Maybe adding some entry in /etc/hosts would have also work for you.
(15 Aug '12, 06:59)
kaysa ♦♦
Hi Kaysa, I had to take a break from this specific task while developing coursework for another project. Unfortunately I can't tell which user is running the cron task. Using sudo php worked, but I don't know why. The folks at the Moodle forums posted a possible solution to idntify the user and create a more reliable cron, but I haven't yet been able to test it. I'll be trying it this weekend.
(13 Sep '12, 10:20)
deverezieaux
showing 5 of 15
show all
|
Hi,
Similar problem. Running from web using domain/admin/cron.php? works but I cant get working with crontab. Followed Beltrans instructions to set up and changed output to /tmp/log.txt but no output appears. Also tried running "/opt/bitnami/php/bin/php /opt/bitnami/apps/moodle/htdocs/admin/cli/cron.php" from cmd line and get following error
"PHP Notice: Undefined index: HTTP_HOST in /opt/bitnami/apps/moodle/htdocs/config.php on line 97 !!! Detected incorrect $CFG->wwwroot in config.php, it must not contain trailing slash.
Please notify server administrator. !!!"
You can to edit the /opt/bitnami/apps/moodle/htdocs/config.php file and replace the wwwroot option with your domain name. We configured to HTTP_POST to be able to access using any domain. You can find more info at http://wiki.bitnami.org/Applications/BitNami_Moodle#How_to_change_the_default_URL.3f Thanks for posing it I will update the crontab documentation.