-2

I want to setup a cronjob for PHP script in ubuntu

I have a script just I want to know how to set it.

* 3 * * * /var/www/html/booking_cron.php
Melebius
  • 11,121
  • 8
  • 50
  • 77
DeepakB
  • 21
  • 4
  • Check if the script is executable first. Then try to run it in Cron and if you get an error, try to google it first and ask a more specific question if your research is unsuccessful. – Melebius Mar 29 '18 at 10:53
  • yes my script is ru and i m set it into windows but i dont kw how to set in ubantu - if i run * 3 * * * /var/www/html/booking_cron.php this command can set it – DeepakB Mar 29 '18 at 10:54
  • After [your comment to the answer](https://askubuntu.com/questions/1020219/setup-a-cronjob-for-php-script-in-ubuntu-php#comment1656278_1020220) I must ask: Have you installed PHP on your Ubuntu yet? – Melebius Mar 29 '18 at 12:39
  • @Melebius yes i have php and mysql in my ubantu machine – DeepakB Mar 30 '18 at 11:35
  • What's your question? What do you expect to happen and what happens instead? Can you run the command `/var/www/html/booking_cron.php` as it is (i. e. without specifying the PHP interpreter explicitly) from a terminal? (see also [How do I ask a good question?](/help/how-to-ask)) Please [edit] your post when you want to clarify something or add information? It’s best to have everything relevant in one place. Additionally, comments may be deleted for various reasons. Thanks. – David Foerster Apr 12 '18 at 21:55

1 Answers1

1

You need to call php binary with argument of the php script:

* 3 * * * /usr/bin/php /var/www/html/booking_cron.php

Be sure your path to php binary is correct.

To find the path to php: which php or find / -name php

Melebius
  • 11,121
  • 8
  • 50
  • 77
kukulo
  • 1,995
  • 10
  • 21