2014-06-24 45 views
0

我一直在試圖創建一個似乎沒有工作的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 
    ~    
    ~                 
+0

'是不是需要cron作業sudo'如果作業可以在您的帳戶正常運行。 「爲什麼不」不是一個很好的理由,當你不知道的時候使用'sudo'。 – Evert

+0

但是好奇的是:爲什麼你想運行一個PHP網頁作爲cron工作?如果它不是網頁,我不會將它粘貼在'/ var/www /'中。 – Evert

+0

我想用sudo來測試它,只是爲了看看權限是否會受到阻礙。我想運行一個PHP腳本作爲一個cron,因爲它的腳本語言我知道(我知道的所有hokery pokery都是在php中)......但是我很快就會學習python ......我現在看到了它的需要! – user3768071

回答

0

如果您還沒有準備好,嘗試用這個命令/etc/init.d/crond start啓動cron服務。希望這有助於,讓我們知道如果它不。

+0

按照您輸入的命令嘗試了該命令,這裏是錯誤消息-bash:/etc/init.d/crond:沒有這樣的文件或目錄 – user3768071

+0

嘗試使用sudo權限。 – Jamie1596

+0

得到這個錯誤信息... sudo:/etc/init.d/crond:找不到命令 – user3768071

相關問題