Moodle 计划任务是由 cron.php 来执行的。Moodle 2.9 以后是不能进行如下操作:
http://your.moodle.site/admin/cron.php
You can change this in ’ Dashboard ► Site administration ► Security ►Site policies ’ by deselecting ‘Cron execution via command line only’.
- You will be warned that ‘Running the cron from a web browser can
expose privileged information to anonymous users. Thus it is
recommended to only run the cron from the command line or set a cron
password for remote access.’ - You can then write a ‘Cron password for remote access’. If this field
is left empty, no password is required. - This means that the cron.php script cannot be run from a web browser
without supplying the password using the following form of URL:
从以上说明可以看出,这个是可以后台设置的,但是有安全风险,具体访问链接如下:
http://site.example.com/admin/cron.php?password=opensesame
当然肯定有更稳妥的办法,那就是通过命令行来执行:
/usr/bin/php /path/to/moodle/admin/cli/cron.php >/dev/null
CentOS平台完整的计划任务配置如下(crontab 命令请自行查阅):
[root@localhost]# crontab -e
[root@localhost]# 0 0 * * * /usr/bin/php /path/to/moodle/admin/cli/cron.php >/dev/null
官方文档见:https://docs.moodle.org/38/en/Cron