来自cpanel的php cron作业不工作。电子邮件中没有错误
我在mySQL数据库中上传了一个简单的cron.php和insert cron.php来自cpanel的php cron作业不工作。电子邮件中没有错误,php,mysql,cron,Php,Mysql,Cron,我在mySQL数据库中上传了一个简单的cron.php和insert cron.php #!/bin/bash mysql --user=[myUsernameToDatabase] --password=[myPasswordToDatabase] --database=[myDatabaseName] --execute="INSERT INTO room (room_name,room_guid) VALUES ('test', 'testing')" 我在cpanel->Cron Jo
#!/bin/bash
mysql --user=[myUsernameToDatabase] --password=[myPasswordToDatabase] --database=[myDatabaseName] --execute="INSERT INTO room (room_name,room_guid) VALUES ('test', 'testing')"
我在cpanel->Cron Jobs中添加了这个
常用设置:一分钟
命令:/usr/bin/php-q/home/myUsername/public\uhtml/cron.php
我每分钟都会收到电子邮件,其中包含我在cron jobs->Command中添加的代码,没有错误。但我的数据库中没有添加任何内容
如果我在数据库中运行测试查询,它可以正常工作
INSERT INTO room (room_name,room_guid) VALUES ('test', 'testar')
您试图以
PHP
的形式运行bash
shell脚本,这根本不起作用。在有机会成功执行之前,您需要做以下几件事:
1. Rename cron.php to cron.sh
2. DO NOT put the script in your `public_html` directory.
locate it somewhere not public (eg. /home/myUsername/scripts/).
3. Try using this in your crontab:
/bin/sh /home/myUsername/scripts/cron.sh 2>&1
至少这会让事情更好地正常工作。这是您正在使用的
bash
脚本,而不是PHP
。我还测试了在cron jobs->command中编写脚本,但收到错误消息。或者我如何使用它?我与cpanel共享主机。您能看到任何错误输出吗?谢谢。我在电子邮件中收到此错误:意外标记“(”)附近出现语法错误。我的数据库密码中有“(”。例如密码“24m(J23)。请尝试将密码打勾“如果我将密码打勾”“我收到错误”错误1045(28000):用户“[myUser]”的访问被拒绝@'localhost(使用密码:是)”