How to to run PHP script every hour (how to add php to cron)

Post Reply
User avatar
myVesta
Site Admin
Posts: 998
Joined: Fri Jun 19, 2020 9:59 am
Has thanked: 10 times
Been thanked: 6 times

For example, let's say you want to run php script wp3.deb12.dev/pinn/insertDataMain.php every hour.

First, check what PHP version you are running.

Screenshot_1.png
Screenshot_1.png (84.83 KiB)

PHP-FPM-80 means that PHP version is 8.0

Now, let's add a cron:

Screenshot_2.png
Screenshot_2.png (60.98 KiB)

Because we are running PHP 8.0 and our URL is wp3.deb12.dev/pinn/insertDataMain.php, and let's say we are under the test account, our CRON command should look like:

Code: Select all

php8.0 /home/test/web/wp3.deb12.dev/public_html/pinn/insertDataMain.php > /home/test/php_cron.log 2>&1
Screenshot_3.png
Screenshot_3.png (112.02 KiB)
Post Reply