我一直在試圖創建一個似乎沒有工作的cron。我正在運行Ubuntu 14.04。爲了測試我已經設置了我的cron每分鐘運行。試圖在Ubuntu服務器上創建一個cron
順便說一句,我創建了使用'sudo crontab -e'的cron。不知道是否需要sudo,但認爲爲什麼不在權限可能是一個問題(順便說一句,PHP腳本運行良好從命令行沒有sudo)
這裏有幾個變化,我試過了,但不要這裏「T工作,
1 * * * * /usr/local/bin/php /var/www/html/test/index.php
1 * * * * /var/www/html/test/index.php
和,是我的cron(整件事)...
# 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
1 * * * * /var/www/html/test/index.php
~
~
'是不是需要cron作業sudo'如果作業可以在您的帳戶正常運行。 「爲什麼不」不是一個很好的理由,當你不知道的時候使用'sudo'。 – Evert
但是好奇的是:爲什麼你想運行一個PHP網頁作爲cron工作?如果它不是網頁,我不會將它粘貼在'/ var/www /'中。 – Evert
我想用sudo來測試它,只是爲了看看權限是否會受到阻礙。我想運行一個PHP腳本作爲一個cron,因爲它的腳本語言我知道(我知道的所有hokery pokery都是在php中)......但是我很快就會學習python ......我現在看到了它的需要! – user3768071