Crontab cannot execute php solution, crontabphp. Crontab cannot execute php. crontabphp analyzes the solution that crontab cannot execute php. For your reference, refer to the following solution: crontab cannot execute php when running the php program with crontab: crontabphp
This article analyzes how crontab cannot execute php. We will share this with you for your reference. The details are as follows:
When you use crontab to run the php program, how can you debug it. I also have a set of methods. let's take a look at how I solve the problem that crontab cannot execute the php program.
I. is there any execution permission for the PHP file?
The code is as follows: [root @ linux cron] # ls-al | grep del
-Rwxr-xr-x 1 zwh ftpgroup 494 10-20 16:42 del_redis.php
If there is no X, it indicates that no execution permission is available, and of course it cannot be executed. If you do not know whether the Group of the user you log on to has permissions, simply add permissions to all groups. The method is as follows:
The code is as follows: [root @ linux cron] # chmod + x./del_redis.php
2. if you have the execution permission, you still cannot execute it.
The solution is as follows:
1. it is also necessary to write logs (for example, error_log () in a php program, because crontab is scheduled for execution. if there is no log, how do you know the program execution result. In this way, we can view the execution of crontab through log.
2. you can also directly output the execution result to a file in crontab. Then, view the execution status in the file. For example:
The code is as follows: */10 *****/usr/local/php/bin/php/var/www/cron/del_redis.php>/home/zhangy/cron.txt
3. use crontab to execute php. apache and nginx are not supported. Therefore, $ _ SERVER and $ _ ENV variables cannot be used at all. So check if there are any such variables in the php code, if they are removed.
4. php relative path problems
This problem is also the easiest to ignore because you have a mindset.
The code is as follows: include_once './mysql. php ';
When php code uses a relative path, it takes effect only when/usr/local/php/bin/php/var/www/cron/level_rank.php is in that directory. I have encountered this problem for at least two times, but I still cannot remember it.
The solution is as follows:
The code is as follows: */10 ***** cd/var/www/cron &/usr/local/php/bin/php/var/www/cron/level_rank.php
Or use absolute paths in php code.