Linux中的Cron工作用于运行php文件

I have an php file to create a new text file . That has to run in every minute . I stored that file on /var/www/html/cron.php . Also i had done in command prompt

crontab -e

edit the file like

* * * * * /var/www/html/cron.php

But still cron not working on localhost

The command you put in crontab should be something like:

*/10 * * * *   /usr/bin/php  /var/www/html/cron.php

Where /usr/bin/php is an example path to your php binary.

You can find out your php binary with:

whereis php

you need to specify in the cron the command to execute, i.e

[cron time] [command to execute]

/var/www/html/cron.php is not a command just a file, you need to use something like

* * * * * php /var/www/html/cron.php 

*better to use full path of php bin instead of php

This should work:

*/1 * * * * cd /var/www/html;./cron.php