This question already has an answer here:
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?
</div>
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