How do I run my cron job on a specific PHP version?

How do I run my cron job on a specific PHP version?

To run a cron job using a specific PHP version, you can use the following example code:

/opt/alt/php81/usr/bin/php -q FILE_PATH

Where "php81" is the PHP version you want to use (PHP 8.1) and can be changed to suit your needs. Such as php72, php73, etc.

The "FILE_PATH" is the full path to the file you want the cron job to run, such as:

/home/myusername/public_html/cron.php

The full command using PHP 8.1 would then be:

/opt/alt/php81/usr/bin/php -q /home/myusername/public_html/cron.php


If you have any further questions, please feel free to open a ticket with us!


    • Related Articles

    • How do I use a different PHP version in a subdomain or folder?

      There are times you may find the need to use a specific PHP version for a subdomain application that is different from your main account PHP version. The following will show you how to use a different PHP version in specific folder and/or subdomain ...
    • What is the default cron path in Enhance control panel?

      The article describes the default cronjob path for your website in Enhance Control Panel. The default path for PHP in Enhance is /usr/bin/php, and the path for your home directory can be achieved in two ways, you can use /var/www/{uuid of website} ...
    • How to change the PHP version in Enhance Control Panel?

      Let's see how you can change the PHP version on your account/website. 1. Once you have logged in to the control panel at https://hub.hivium.com, go to the websites section. 2. Now hover over the "Advanced" option as seen in the below screenshot and ...
    • How to solve the error related to PHP session save path?

      If you receive an error stating the PHP session path is not writable, you can simply update the session.save_path setting in the PHP Selector. From the Extra Features menu item in DirectAdmin: 1. Open Select PHP Version 2. Click Options 3. For the ...
    • What to do when we see Forbidden: PHP engine is disabled?

      If you receive the error “Forbidden: PHP engine is disable”, it is due to “PHP Access” for the domain not being enabled. To enable it, simply go to Domain Setup in DirectAdmin and choose Modify. From there you can click the checkbox for PHP Access ...