打開殼和輸入:
command="php /opt/lamt/htdocs/refresh.php"
job="30 22 * * * $command"
cat <(fgrep -i -v "$command" <(crontab -l)) <(echo "$job") | crontab -
上面創建在22.30
每天執行/opt/lamt/htdocs/refresh.php
一個cronjob。
command="php /opt/lamt/htdocs/refresh.php"
job="30 10 * * * $command"
cat <(fgrep -i -v "$command" <(crontab -l)) <(echo "$job") | crontab -
以上創建在10.30
每天執行/opt/lamt/htdocs/refresh.php
一個cronjob。
這是正確的語法crontab
:
# * * * * * command to execute
# ┬ ┬ ┬ ┬ ┬
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ └───── day of week (0 - 7) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
# │ │ │ └────────── month (1 - 12)
# │ │ └─────────────── day of month (1 - 31)
# │ └──────────────────── hour (0 - 23)
# └───────────────────────── min (0 - 59)
Source
我想你一定打電話給你文件使用'php -f/opt/lamt/htdocs/refresh.php' – Cyclonecode
「contab -e」來編輯你的cron時間表。 – Xardas