Cron工作不在Homestead工作

时间:2015-12-03 19:52:03

标签: linux laravel ubuntu cron homestead

我在win8笔记本电脑上运行Homestead,而我的Cron似乎根本没有运行。我正在努力让预定的工作岗位为Laravel工作,但我现在仍然坚持要让Cron全力以赴。

这是我的crontab,只是一些简单的尝试调试它。

fufu.com/vfd

使用crontab -e尝试编辑我的crontab时,这看起来是否正确?

vagrant@homestead:~$ crontab -l
* * * * * date >> /home/vagrant/Code/CRONTRACK.txt
* * * * * /usr/bin/php artisan schedule:run >> /home/vagrant/Code/laravel_cron_output.txt

现在,当我尝试检查我的系统,看看cron是否运行了什么

vagrant@homestead:~$ crontab -e
143

好像有用了,但我找不到我输出到输出的txt文件了!

vagrant@homestead:~$ 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)

运行我在终端直接给Cron的命令完全正常!

vagrant@homestead:~$ cat /home/vagrant/Code/CRONTRACK.txt^M
cat: /home/vagrant/Code/CRONTRACK.txt^M: No such file or directory
vagrant@homestead:~$ cat /home/vagrant/Code/CRONTRACK.txt
cat: /home/vagrant/Code/CRONTRACK.txt: No such file or directory
vagrant@homestead:~$ 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/
vagrant@homestead:~$

此外,^ M来自哪里?它没有出现在crontab -l中。

1 个答案:

答案 0 :(得分:1)

问题已解决。 我在记事本中创建了我的crontab文件,它附加了回车,而linux并不喜欢我的新行。

crontab -l

没有透露CR(我不明白为什么不能解决它的问题呢?!?!)。

因此,使用notepad ++和sublime文本来查找并解决问题。