我正在尝试在我的AWS EC2实例上设置cronjob。 crontab文件中的实际条目没有任何问题,但是当我尝试在命令行中运行该命令时,我得到了这个响应。
PHP Warning: include(../scripts/connect.php): failed to open stream: No such file or directory in /var/www/htdocs/crons/emailnotifications.php on line 2
PHP Warning: include(): Failed opening '../scripts/connect.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/htdocs/crons/emailnotifications.php on line 2
PHP Warning: include(../scripts/functions.php): failed to open stream: No such file or directory in /var/www/htdocs/crons/emailnotifications.php on line 3
PHP Warning: include(): Failed opening '../scripts/functions.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/htdocs/crons/emailnotifications.php on line 3
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'UTC/0.0/no DST' instead in /var/www/htdocs/crons/emailnotifications.php on line 4
PHP Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /var/www/htdocs/crons/emailnotifications.php on line 6
PHP Warning: mysql_query(): A link to the server could not be established in /var/www/htdocs/crons/emailnotifications.php on line 6
PHP Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /var/www/htdocs/crons/emailnotifications.php on line 7
我可以在浏览器中加载此页面并且工作正常,但不是从命令行(或cronjob)。
答案 0 :(得分:1)
使用要包含的文件的绝对路径
答案 1 :(得分:0)
请看这条路:/var/www/htdocs/crons/emailnotifications.php 我认为没有emailnotifications.php文件。所以这个文件不包括在内。如果未包含此文件,则会出现其他错误
答案 2 :(得分:0)
使用这种方式: -
include(require dirname(__FILE__) .'/../scripts/connect.php');
require_once dirname(__FILE__) . '/../inc/function.php';