Setting up the cron in a centOS 6.3 server

Setting up the cron in a centOS 6.3 server

- Mari Cruz García の投稿
返信数: 5

Hello,

 

I would like to set up the cron for a Moodle 2.5 I have installed in a cenTOS 6.3. It is the first time that I work with centOS and I am an educational technologist, so please don't take things for granted in your reply.

When I looked into the Moodle.org documentation:

/usr/bin/sudo -u apache /usr/local/zend/bin/php-cli /var/www/html/moodle/admin/cli/cron.php

Zend server is not installed in my server.

I have added the zen repo file in  my /etc/yum.repos.d/

and when I run the command:

yum install zend-server-php-5.3

 

I get an error message I cannot understand (see below).

I cannot upgrade the OS of my server.

1) I only want to configure the cron. Is there a way of doing it without installing Zend?

2) What5 are the implications of installing Zend server? Will it affect Apache, MySQL or the Shibboleth deamon which is running in my server?

 

Thank you very much for your advice.

Mari Cruz

 

Error: Package: php-devel-5.3.3-14.el6_3.x86_64 (@centos6.3-x86_64.updates)
           Requires: php = 5.3.3-14.el6_3
           Removing: php-5.3.3-14.el6_3.x86_64 (@centos6.3-x86_64.updates)
               php = 5.3.3-14.el6_3
           Obsoleted By: mod-php-5.3-apache2-zend-server-5.3.21-9.x86_64 (Zend)
               Not found
           Available: php-5.3.3-3.el6_2.8.x86_64 (BaseOS)
               php = 5.3.3-3.el6_2.8
           Installing: php-5.3-fcgi-zend-server-5.3.21-6.x86_64 (Zend)
               php = 5.3.21-6
           Available: php-5.4-fcgi-zend-server-5.4.11-6.x86_64 (Zend)
               php = 5.4.11-6
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

___________________________________________________________________________________

Mari Cruz García への返信

Re: Setting up the cron in a centOS 6.3 server

- Howard Miller の投稿
画像 Core developers 画像 Documentation writers 画像 Particularly helpful Moodlers 画像 Peer reviewers 画像 Plugin developers

I don't understand what Zend has to do with anything. You don't need it for Moodle and certainly not for cron.

The documentation is here - Cron - I'm unsure what you have been looking at.

Howard Miller への返信

Re: Setting up the cron in a centOS 6.3 server

- Ken Task の投稿
画像 Particularly helpful Moodlers

+1 to the link for Cron setup.   However, the doc there shows examples of Linux OS's other than what you are running.   Translation to CentOS-ese is needed ... example apache user in CentOS is 'apache'.   If you have root access sudo is not needed.

To test:

cd /var/www/html/[moodle] location of moodle code

php admin/cli/cron.php

Note that full path to php is not needed.   Relative path to the cron.php file, however, is.

If you can run that, without sudo, good!

Docs mention wget but one also has potentially the ability to use curl.

To see if you have either of those:

whereis wget

whereis curl

If they are present on your system, the commands above will return the path to them.

http://docs.moodle.org/24/en/Cron_with_Unix_or_Linux

shows both wget and curl.

Tip: both, either wget or curl, one must use a URL.  That does launch an apache process.

With simple command line, script which would be placed in /usr/local/bin/ or for that matter just about anywhere on the system (this method uses only PHP - no apache involved):

cd /usr/local/bin/

nano runcron

in the runcron script:

php /full_path_to_moodle_code_directory/admin/cli/cron.php

Save the file and then make it executable:

chmod u+x runcron

Test it ... from any location (/root) ... runcron [ENTER]

You could then point your cron job to that script and have the ability to run the script on demand from command line - handy to have if one is about to upgrade or do other admin task with Moodle.

'spirit of sharing', Ken

Mari Cruz García への返信

Re: Setting up the cron in a centOS 6.3 server

- Ken Task の投稿
画像 Particularly helpful Moodlers

Follow up ... for others who might run across this ... repeat:  Zend Server not required for setting up cron with CentOS 6.3 (older boxen).   Maybe this is the info the poster saw which lead to the question. (just got this via EMail).

http://app.news.zend.com/e/es.aspx?s=714&e=694277&elq=3887663583af4810b799124ac68547da

IF (notice that's IF) your college will not be doing any upgrade to the OS of your server nor opening the server to those 3rd party repos, Zend Server does offer support for version 5.3 of PHP until February 2017.

'spirit of sharing', Ken

Mari Cruz García への返信

Re: Setting up the cron in a centOS 6.3 server

- Simon Trendell の投稿

I'm assuming that you have Moodle running and can login etc etc, so you must have Apache, PHP and Postgres/MySQL installed, probably via Yum.

My cron is setup as follows on CentOS 5.10 but hopefully the instructions should be the same.

 

1. Find your php install location

which php

Should show something similar to /usr/bin/php

2. Edit the Crontab (Schedule Tasks) for the Apache user

sudo crontab -eu apache

3. By default this will use vi which is always interesting. You should get an empty editor, press i to enter Insert mode.

4. Type the following line

*/10 * * * * /usr/bin/php /path/to/your/moodle/cli/cron.php > /dev/null

Change both the path to your PHP and your Moodle installation path. This will run every 10 minutes, you can change that if you want.

5. Press ESC and then type :wq and press Enter

Hopefully you should see "crontab: installing new crontab" and that should be it provided all your paths are correct.

Simon Trendell への返信

Re: Setting up the cron in a centOS 6.3 server

- Howard Miller の投稿
画像 Core developers 画像 Documentation writers 画像 Particularly helpful Moodlers 画像 Peer reviewers 画像 Plugin developers

On some systems the web server user ('apache' here but could be several different things) may not have permission to use cron.

TBH, I usually use either the 'root' user or (on shared servers) the owner of the Moodle site for the cron job. Even though it theory it could permissions problems down the line it's never happened to me.