Gopinath Parthee
Gopinath Parthee

Reputation: 70

Cron job in linux for running php file

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

Upvotes: 0

Views: 1700

Answers (3)

Walid Da.
Walid Da.

Reputation: 948

This should work:

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

Upvotes: 0

shahaf
shahaf

Reputation: 4983

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

Upvotes: 3

Shuwn Yuan Tee
Shuwn Yuan Tee

Reputation: 5748

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

Upvotes: 1

Related Questions