[英]crontab not running php script
crontab在某一點上運行正常,但運行一天后它刪除了/var/spool/cron/crontabs
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.DYqvRY/crontab installed on Thu Mar 17 14:50:32 2016)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
# Edit this file to introduce tasks to be run by cron.
#
# 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
0 0 1 * * /var/www/html/mail.php
0 0 16 * * /var/www/html/mail.php
0 13 2 * * /var/www/html/mailcheck.php
0 13 17 * * /var/www/html/mailcheck.php
0 13 2 * * /var/www/html/mailcheckadmin.php
0 13 17 * * /var/www/html/mailcheckadmin.php
0 0 1 * * /var/www/html/PaymentPeriod_Create.php
0 0 16 * * /var/www/html/PaymentPeriod_Create.php
* * * * * /var/www/html/testsession.php > /var/www/html/log
我正在使用# crontab -e
來編輯這個文件然后當我完成后我按^ XY ENTER是否有任何額外的步驟,我缺少* * * * * /var/www/html/testsession.php > /var/www/html/log
這應該每分鍾運行一次嗎?
語法* * * * * /var/www/html/testsession.php > /var/www/html/log
有效。
很可能,因為它是crontab中的最后一行,它缺少換行符。 Cron在每個條目的末尾都需要換行; 換句話說,你的crontab必須以空行結束。
從man crontab
的“Diagnostics”部分:
cron要求crontab中的每個條目都以換行符結尾。 如果crontab中的最后一個條目缺少換行符,cron將認為crontab(至少部分)已損壞並拒絕安裝它。
您可能希望將>
替換為>>
以便將新內容附加到日志文件而不是每分鍾覆蓋它,即* * * * * /var/www/html/testsession.php >> /var/www/html/log
。 如果日志文件尚不存在,它仍將創建日志文件。
您的PHP文件還需要設置執行位,並且需要在第一行以#!/usr/bin/php
(或系統上的PHP路徑)開頭。 或者,您可以用* * * * * /usr/bin/php /var/www/html/testsession.php >> /var/www/html/log
替換cron行,以顯式使用PHP解釋器來執行腳本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.