Cron在运行时无法打开输入文件

时间:2020-04-05 07:00:24

标签: php cron cpanel

我不知道cron jobs,我想在cPanel中设置它们,所以我有2个php文件正在尝试运行:

covid-19_data.php

还有utilities.php

我在cPanel上运行:

/usr/local/bin/php -q -f /public_html/wp-content/themes/siteName/scripts/data/shared/utilities.php

/usr/local/bin/php /home/siteName/public_html/wp-content/themes/siteName/scripts/covid-19_data.php

但是我一直收到:

Could not open input file: /public_html/wp-content/themes/siteName/scripts/data/shared/utilities.php

Warning: include_once(../shared/utilities.php): failed to open stream: No such file or directory in /home1/siteName/public_html/wp-content/themes/siteName/scripts/covid-19_data.php on line 3

Warning: include_once(): Failed opening '../shared/utilities.php' for inclusion (include_path='.:/opt/php56/lib/php') in /home1/siteName/public_html/wp-content/themes/siteName/scripts/covid-19_data.php on line 3

Warning: chdir(): No such file or directory (errno 2) in /home1/siteName/public_html/wp-content/themes/siteName/scripts/covid-19_data.php on line 12

Fatal error: Call to undefined function downloadFile() in /home1/siteName/public_html/wp-content/themes/siteName/scripts/covid-19_data.php on line 16

我尝试每分钟运行utilities.php,每两分钟运行covid-19_data.php,但是没有用。

当我需要使其运行时,我仅通过浏览器wwww ... covid-19_data.php手动运行并且可以正常运行,我不需要运行utilities.php,我仅使其运行即可尝试如果那是问题。

1 个答案:

答案 0 :(得分:0)

这听起来像是您的主机以nobody的身份运行cron作业,或某些其他无法访问您帐户中文件的用户。尝试更改covid-19_data.php的权限以允许“其他”读取/执行它:

chmod o+rx /home/siteName/public_html/wp-content/themes/siteName/scripts/covid-19_data.php