[英]Cron job error for php file
I'm developing an app that should runs once a day a PHP script for sending mail and SMS. 我正在开发一个应每天运行一次用于发送邮件和SMS的PHP脚本的应用程序。
I'm new to use cron jobs, i've set correctly the crontab, the PHP file is running but I receive this error : 我是刚使用cron作业的人,我已经正确设置了crontab,PHP文件正在运行,但是我收到此错误 :
/srv/applicazioni/shuttle/server/mylac.php: line 1: ?php: No such file or directory
/srv/applicazioni/shuttle/server/mylac.php: line 2: syntax error near unexpected token `'/data/applicazioni/shuttle/server/phpmailer/PHPMailer-master/''
/srv/applicazioni/shuttle/server/mylac.php: line 2: `set_include_path('/data/app'icazioni/shuttle/server/phpmailer/PHPMailer-master/');
This is the point in the script that I receive the error: 这是我收到错误的脚本要点:
<?php
set_include_path('/data/applicazioni/shuttle/server/phpmailer/PHPMailer-master/');
require 'PHPMailerAutoload.php';
?>
The file PHPMailerAutoload.php
on the server is in /data/applicazioni/shuttle/server/phpmailer/PHPMailer-master/
服务器上的文件
PHPMailerAutoload.php
位于/data/applicazioni/shuttle/server/phpmailer/PHPMailer-master/
How can i solve it? 我该如何解决?
Thank's 谢谢
Cron scripts are expected to be shell scripts, and <
is a redirect operator in a shell, so when you say: Cron脚本应该是Shell脚本,而
<
是Shell中的重定向运算符,因此当您说:
<?php
that's saying "get input from a file called ?php
", which of course doesn't exist, so you get ?php: No such file or directory
. 就是说“从名为
?php
的文件获取输入”,这当然是不存在的,所以您得到?php: No such file or directory
。 You need to add a "hashbang" to the start of your file to tell it to run the script using the PHP interpreter: 您需要在文件的开头添加“ hashbang”,以使其使用PHP解释器运行脚本:
#!/usr/bin/env php
<?php
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.