运行命令我正在使用 ubuntu 12 和 lamp 服务器。我想每 1 小时运行一次 php 脚本。我已经创建了一个 crontab 来执行此操作,如果我使用命令 crontab -l 检查我的 cron 列表,它会显示如下
# Edit this file to introduce tasks to be run by cron.
0 * * * * /usr/bin/php5 -q /var/www/cronjobs/cron1.php
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
这是我的 php 脚本
0 * * * * /usr/bin/php5 -q /var/www/cronjobs/cron1.php
但它没有执行
我怎样才能检查为什么它不起作用,请帮忙
您可以使用 crontab 添加/删除/编辑 cronjobs。
按 Alt+Ctrl+T 打开终端。
首先通过运行以下命令确保脚本可执行:
chmod +x YOURSCRIPT
然后运行以下命令来添加您的 cronjob:
crontab -e
像这样添加你的 cronjob:
0 * * * * /usr/local/bin/php path/of/php/file
就是这样!
您可以通过运行以下命令来检查当前用户的 crontab 条目:
crontab -l
有关 crontab 运行的更多信息:
crontab --help
OR
man crontab
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)