php - PHP 的问题包括来自命令行(或 cronjob)

标签 php linux amazon-ec2 cron sysadmin

我正在尝试在我的 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)。

最佳答案

对要包含的文件使用绝对路径

关于php - PHP 的问题包括来自命令行(或 cronjob),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25165334/

相关文章:

php - MySQL FULL JOIN 一个表,并在同一个查询中 LEFT JOIN 另一个表?

linux - 按修改时间对文件(包括所有子目录中的文件)进行排序

git - 找不到 git 更新后 Hook 中的 Bash 命令

amazon-web-services - 无法将公共(public)弹性 IP 绑定(bind)到运行 Windows Server 2016 的 EC2 上的 Elasticsearch

php - 为什么我的 PHP 文件显示为纯文本?

php - 使用 PHP 和 MySQLi 连接后如何更改 SQL_MODE 和 FOREIGN_KEY_CHECKS?

linux - 在 Bash 中将多个摄氏度值转换为华氏度

linux - 在 Linux shell bash 脚本中,如何在同一行打印到文件?

wordpress - 如何设置 Azure Web 应用程序 URL 以通过 AWS Route53 进行路由?

javascript - 在 jquery-easyui 中禁用多次点击保存按钮