Executing a PHP script with a CRON Job [closed]
Solution 1:
Crontab needs the full path on your server.
0 0 * * * php /var/www/vhosts/domain.com/httpdocs/scripts/example.php
This will execute every day at midnight.
Solution 2:
If You have a sudo access to your linux server :- Then do the following
sudo crontab -e
This will open the cron tab for you on your server.
Next thing is you have to do a cron entry for the file which you want to execute
00 00 * * * /usr/local/bin/php "path of the php file which you want to execute"
00 00 * * *
this will run your cron at midnight daily, means at 0hrs and 0mins
Solution 3:
So something like this:
00 * * * * /usr/local/bin/php /home/john/myscript.php
The 00 * * * * means hourly /usr/local/bin/php - where php main engine is in /home/john/myscript.php - the script to run (physical path)
You can use also @hourly special key:
@hourly /usr/local/bin/php /home/john/myscript.php