-4

I' never done something like that and I don't even know if it is possible. In my website, I have a .php file that reads a .json file and update the database according to this .json.

I want the server to execute this .php script every hour(or something like that).

Is that possible? How do I do that? If it is impossible, why?

j08691
  • 204,283
  • 31
  • 260
  • 272
ahmm95
  • 95
  • 1
  • 9

1 Answers1

3

Yes, this is absolutely possible, assuming you have php5-cli installed.

Just type crontab -e, and then add the following line. This will cause php to be run with your script as an argument every hour, on the hour.

0 * * * * php path/to/MyScript.php

Alternately, you can put #!/usr/bin/php at the top of your script, do chmod +x MyScript.php and replace the line above the following.

0 * * * * path/to/MyScript.php
merlin2011
  • 71,677
  • 44
  • 195
  • 329