Moodle Cron问题解决过程回顾

什么是Cron?

Some of Moodle's modules require continual checks to perform tasks. For example, Moodle needs to check the discussion forums so it can mail out copies of posts to people who have subscribed. 

The script that does all this is located in the admin directory, and is called cron.php. However, it can not run itself, so you need to set up a mechanism where this script is run regularly (eg every five or ten minutes). This provides a "heartbeat" so that the script can perform functions at periods defined by each module. This kind of regular mechanism is known as a cron service. 

Note that the machine performing the cron does not need to be the same machine that is running Moodle.For example,if you have a limited web hosting service that does not have a cron service,then you might choose to run cron on another server or on your home computer.All that matters is that the cron.php file is called regularly. 



n       如何使Cron,php自动运行?

远程登录(或直接登录)基于Linux系统的服务器进行一些命令操作就可以了。

All that Cpanel does is provide a web interface to a Unix utility known as crontab. If you have a command line, you can set up crontab yourself using the command: 

crontab –e

说明:the "crontab -e" command will put you into the 'vi' editor.

这里的example.com是Moodle网址。服务器上应安装wget。

and then adding one of the above commands like: 

*/30 * * * * wget -q -O /dev/null http://example.com/moodle/admin/cron.php

说明: 

如果需要5分钟运行一次,只要把“30”改为“5”就可以了。

The first five entries are the times to run values, followed by the command to run. The asterisk is a wildard, indicating any time. The above example means run the command wget -q -O /dev/null... every 30 minutes (*/30), every hour (*), every day of the month (*), every month (*), every day of the week (*). 

The "O" of "-O" is the capital letter not zero, and refers the output file destination, in this case "/dev/null" which is a black hole and discards the output. If you want to see the output of your cron.php then enter its url in your browser. 

For beginners, "EDITOR=nano crontab -e" will allow you to edit the crontab using the nano editor. Ubuntu defaults to using the nano editor. 

You enter "insert mode" by pressing "i", then type in the line as above, then exit insert mode by pressing ESC. You save and exit by typing ":wq", or quit without saving using ":q!" (without the quotes). Here is an intro to the 'vi' editor. 

转载于:https://www.cnblogs.com/laipDIDI/articles/2141353.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值