2015-12-03 93 views
1

我在我的win8筆記本電腦上運行Homestead,而我的Cron似乎並沒有運行。我試圖讓預定的工作爲Laravel工作,但我暫時無法讓Cron運行。Cron工作不在Homestead工作

這是我的crontab,只是簡單的嘗試調試它。

[email protected]:~$ crontab -l 
* * * * * date >> /home/vagrant/Code/CRONTRACK.txt 
* * * * * /usr/bin/php artisan schedule:run >> /home/vagrant/Code/laravel_cron_output.txt 

當使用crontab -e嘗試編輯我的crontab時,這看起來是否正確?

[email protected]:~$ crontab -e 
143 

現在,當我嘗試檢查我的系統,看看是否cron的跑什麼

[email protected]:~$ grep CRON /var/log/syslog 
Dec 3 19:41:01 homestead CRON[3628]: (vagrant) CMD (date >> /home/vagrant/Code/CRONTRACK.txt^M) 
Dec 3 19:41:01 homestead CRON[3629]: (vagrant) CMD (/usr/bin/php artisan schedule:run >> /home/vagrant/Code/laravel_cron_output.txt^M) 
Dec 3 19:41:01 homestead CRON[3627]: (vagrant) MAIL (mailed 1 byte of output; but got status 0x004b, #012) 
Dec 3 19:41:01 homestead CRON[3626]: (vagrant) MAIL (mailed 1 byte of output; but got status 0x004b, #012) 
Dec 3 19:42:01 homestead CRON[3635]: (vagrant) CMD (date >> /home/vagrant/Code/CRONTRACK.txt^M) 
Dec 3 19:42:01 homestead CRON[3636]: (vagrant) CMD (/usr/bin/php artisan schedule:run >> /home/vagrant/Code/laravel_cron_output.txt^M) 
Dec 3 19:42:01 homestead CRON[3634]: (vagrant) MAIL (mailed 1 byte of output; but got status 0x004b, #012) 
Dec 3 19:42:01 homestead CRON[3633]: (vagrant) MAIL (mailed 1 byte of output; but got status 0x004b, #012) 
Dec 3 19:43:01 homestead CRON[3642]: (vagrant) CMD (date >> /home/vagrant/Code/CRONTRACK.txt^M) 
Dec 3 19:43:01 homestead CRON[3643]: (vagrant) CMD (/usr/bin/php artisan schedule:run >> /home/vagrant/Code/laravel_cron_output.txt^M) 
Dec 3 19:43:01 homestead CRON[3641]: (vagrant) MAIL (mailed 1 byte of output; but got status 0x004b, #012) 
Dec 3 19:43:01 homestead CRON[3640]: (vagrant) MAIL (mailed 1 byte of output; but got status 0x004b, #012) 
Dec 3 19:44:01 homestead CRON[3649]: (vagrant) CMD (date >> /home/vagrant/Code/CRONTRACK.txt^M) 
Dec 3 19:44:01 homestead CRON[3650]: (vagrant) CMD (/usr/bin/php artisan schedule:run >> /home/vagrant/Code/laravel_cron_output.txt^M) 
Dec 3 19:44:01 homestead CRON[3648]: (vagrant) MAIL (mailed 1 byte of output; but got status 0x004b, #012) 
Dec 3 19:44:01 homestead CRON[3647]: (vagrant) MAIL (mailed 1 byte of output; but got status 0x004b, #012) 
Dec 3 19:45:01 homestead CRON[3656]: (vagrant) CMD (date >> /home/vagrant/Code/CRONTRACK.txt^M) 
Dec 3 19:45:01 homestead CRON[3657]: (vagrant) CMD (/usr/bin/php artisan schedule:run >> /home/vagrant/Code/laravel_cron_output.txt^M) 
Dec 3 19:45:01 homestead CRON[3655]: (vagrant) MAIL (mailed 1 byte of output; but got status 0x004b, #012) 
Dec 3 19:45:01 homestead CRON[3654]: (vagrant) MAIL (mailed 1 byte of output; but got status 0x004b, #012) 

好像它的工作,但我無法找到我的管道輸出到我的txt文件!

[email protected]:~$ cat /home/vagrant/Code/CRONTRACK.txt^M 
cat: /home/vagrant/Code/CRONTRACK.txt^M: No such file or directory 
[email protected]:~$ cat /home/vagrant/Code/CRONTRACK.txt 
cat: /home/vagrant/Code/CRONTRACK.txt: No such file or directory 
[email protected]:~$ ll /home/vagrant/Code/ 
total 82 
drwxrwxrwx 1 vagrant vagrant 4096 Dec 3 18:59 ./ 
drwxr-xr-x 7 vagrant vagrant 4096 Dec 3 19:31 ../ 
-rwxrwxrwx 1 vagrant vagrant 153 Dec 3 19:24 crontab.txt* 
-rwxrwxrwx 1 vagrant vagrant 70449 Oct 15 20:44 memcached-2.2.0.tgz* 
drwxrwxrwx 1 vagrant vagrant 4096 Oct 20 19:05 sample/ 
[email protected]:~$ 

並運行我直接在終端給cron中的命令工作完全正常!

[email protected]:~$ date >> /home/vagrant/Code/CRONTRACK.txt^M 
[email protected]:~$ cat /home/vagrant/Code/CRONTRACK.txt^M 
Thu Dec 3 19:53:06 UTC 2015 

另外,^ M從哪裏來?它不顯示在crontab -l中。

回答

1

問題已解決。 我在記事本中創建了我的crontab文件,它附加了我不喜歡的新回車。

crontab -l 

沒有顯示CR(我不明白爲什麼不,如果它的這樣一個問題爲什麼不適用於linux!?!?)。

因此,它使用記事本+ +和崇高的文本來找到並解決問題。