简体   繁体   English

cPanel 上的 Cron 作业未运行

[英]Cron Job on cPanel not running

I'm trying to run a cronjob in cPanel which gives me the following error:我正在尝试在 cPanel 中运行 cronjob,这给了我以下错误:

Fatal error : Uncaught Error: Class 'mysqli' not found in /home/example/public_html/new_facebook_csv/csv_generator1.php:180致命错误:未捕获的错误:在 /home/example/public_html/new_facebook_csv/csv_generator1.php:180 中找不到类 'mysqli'

If run that file through browser by using the link example.com/new_facebook_csv/csv_generator1.php i get the right resaults without any errors, but if i try to run it with a cron job i get the error "Class 'mysqli' not found".如果使用链接 example.com/new_facebook_csv/csv_generator1.php 通过浏览器运行该文件,我会得到正确的结果而没有任何错误,但如果我尝试使用 cron 作业运行它,则会收到错误“找不到类 'mysqli' ”。

The cron job I'm running is the following:我正在运行的 cron 作业如下:

php /home/example/public_html/new_facebook_csv/csv_generator1.php > /home/example/public_html/new_facebook_csv/facebook.log

and here is the logs i get after the cron job:这是我在 cron 作业后得到的日志:

X-Powered-By: PHP/7.3.22
Content-type: text/html; charset=UTF-8

<br />
<b>Fatal error</b>:  Uncaught Error: Class 'mysqli' not found in /home/example/public_html/new_facebook_csv/csv_generator1.php:180
Stack trace:
#0 {main}
  thrown in <b>/home/example/public_html/new_facebook_csv/csv_generator1.php</b> on line <b>180</b><br />

I added the mysqli extension in the php.ini (extension=php_mysql.dll) but not luck with that.我在 php.ini (extension=php_mysql.dll) 中添加了 mysqli 扩展,但运气不佳。

Also check if mysqli is installed to my server with this commaned:还要检查mysqli是否安装到我的服务器上,这个命令:

php -m|grep mysql

and that was my output那就是我的输出

mysqli
mysqlnd
pdo_mysql

which means that mysql is installed to my server这意味着mysql已安装到我的服务器

try with curl like /usr/bin/curl example.com/new_facebook_csv/csv_generator1.php尝试像/usr/bin/curl example.com/new_facebook_csv/csv_generator1.php这样的 curl

or you can use wget wget -q -O- example.com/new_facebook_csv/csv_generator1.php或者你可以使用 wget wget -q -O- example.com/new_facebook_csv/csv_generator1.php

I'm trying to run a cronjob in cPanel which gives me the following error:我正在尝试在cPanel中运行cronjob,这给了我以下错误:

Fatal error : Uncaught Error: Class 'mysqli' not found in /home/example/public_html/new_facebook_csv/csv_generator1.php:180致命错误:未捕获的错误:在/home/example/public_html/new_facebook_csv/csv_generator1.php:180中找不到类'mysqli'

If run that file through browser by using the link example.com/new_facebook_csv/csv_generator1.php i get the right resaults without any errors, but if i try to run it with a cron job i get the error "Class 'mysqli' not found".如果通过使用链接example.com/new_facebook_csv/csv_generator1.php通过浏览器运行该文件,我将获得正确的重新存储而没有任何错误,但是如果我尝试使用cron作业运行它,则会出现错误“找不到类'mysqli'” ”。

The cron job I'm running is the following:我正在运行的Cron作业如下:

php /home/example/public_html/new_facebook_csv/csv_generator1.php > /home/example/public_html/new_facebook_csv/facebook.log

and here is the logs i get after the cron job:这是我在完成cron工作后得到的日志:

X-Powered-By: PHP/7.3.22
Content-type: text/html; charset=UTF-8

<br />
<b>Fatal error</b>:  Uncaught Error: Class 'mysqli' not found in /home/example/public_html/new_facebook_csv/csv_generator1.php:180
Stack trace:
#0 {main}
  thrown in <b>/home/example/public_html/new_facebook_csv/csv_generator1.php</b> on line <b>180</b><br />

I added the mysqli extension in the php.ini (extension=php_mysql.dll) but not luck with that.我在php.ini中添加了mysqli扩展名(extension = php_mysql.dll),但运气不好。

Also check if mysqli is installed to my server with this commaned:还要检查mysqli是否已通过以下命令安装到我的服务器上:

php -m|grep mysql

and that was my output那是我的输出

mysqli
mysqlnd
pdo_mysql

which means that mysql is installed to my server这意味着mysql已安装到我的服务器上

This is how I scheduled a cron job in cPanel through GoDaddy that runs the script and includes MYSQLI:这就是我通过运行脚本并包含 MYSQLI 的 GoDaddy 在 cPanel 中安排 cron 作业的方式:

curl -s "https://yourwebsite.com/phpscript.php"

在此处输入图像描述

I tried many variations including cPanel's example on running a PHP script with a cron job.我尝试了许多变体,包括 cPanel 关于使用 cron 作业运行 PHP 脚本的示例。 I tried php in front of the script path, and the same format you used above, as well as the suggested answers and I received the same errors.我在脚本路径前面尝试了 php,与您在上面使用的格式相同,以及建议的答案,我收到了相同的错误。 Just using curl -s and then the url of your php script will do the trick.只需使用 curl -s 然后你的 php 脚本的 url 就可以了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM