[英]Execute php script with crontab doesn't work
I'm trying to execute a php script every day to send an automatic email to the clients that have contacted me. 我正在尝试每天执行一个PHP脚本,以便向联系我的客户发送自动电子邮件。 To try if it works I'm trying to execute it every minute. 尝试它是否有效我试图每分钟执行一次。 I have followed these steps: 我已按照以下步骤操作:
whereis php
prompts whereis php
提示的地方 php: /usr/bin/php /usr/share/php /usr/share/man/man1/php.1.gz
2. Then I make crontab -e
and add a line: 然后我制作crontab -e
并添加一行:
* * * * * /usr/bin/php /var/www2/www/centros-sbc.com/public_html/mail/mail_automatico.php &>> /dev/null
Then I wait a minute and nothing happens. 然后我等一下,没有任何反应。 Have any idea? 有什么想法吗?
Every minute is "* * * * *" 每分钟都是“* * * * *”
You've done "every hour at one minute past" 你已经完成了“过了一分钟的每小时”
Have your tried /usr/bin/php -f /var/www2/www/centros-sbc.com/public_html/mail/mail_automatico.php &>> /dev/null 你试过/ usr / bin / php -f /var/www2/www/centros-sbc.com/public_html/mail/mail_automatico.php& >> / dev / null
-f option is here to execute the file (your file) mail_automatico.php -f选项用于执行文件(您的文件)mail_automatico.php
1) check if your cron job is working (service crond status | systemctl status crond) 1)检查你的cron工作是否正常工作(service crond status | systemctl status crond)
2) &>/dev/null
is normally equal to > /dev/null 2>&1
. 2) &>/dev/null
通常等于> /dev/null 2>&1
。 But some shells doesn't support it. 但有些炮弹不支持它。
have you tried > /dev/null 2>&1
instead &>/dev/null
? 你试过> /dev/null 2>&1
而不是&>/dev/null
?
Finally I succeed by making it more simple: 最后,我通过使其更简单成功:
- /usr/bin/php /var/www2/www/centros-sbc.com/public_html/mail/mail_automatico.php / usr / bin / php /var/www2/www/centros-sbc.com/public_html/mail/mail_automatico.php
Thanks to all 谢谢大家
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.