To run a cron job using a specific PHP version in cPanel on Doscast, follow these steps:
1. Check Available PHP Versions:
Log in to your cPanel account on Doscast. Navigate to the "Select PHP Version" section under the "Software" category. Note the PHP versions available (e.g., php72
, php73
, php81
).
2. Prepare Your PHP Script:
Ensure your PHP script is ready and saved in your desired directory. For instance, if your script is named cron.php
, it might be located at:
/home/myusername/public_html/cron.php
3. Access the Cron Jobs Section:
In your cPanel dashboard, find the "Cron Jobs" option under the "Advanced" section.
4. Set Up the Cron Job:
Choose how often you want the cron job to run (like every minute, hourly, or daily).
5. Enter the Command:
In the "Command" field, enter the command to run your script with the specific PHP version. The command will look like this:
/opt/alt/php81/usr/bin/php -q /home/myusername/public_html/cron.php
Replace php81
with the desired PHP version (e.g., php72
for PHP 7.2, php73
for PHP 7.3).
Make sure to replace /home/myusername/public_html/cron.php
with the actual path to your script.
For example, if you want to use PHP 8.1, it would look like:
/opt/alt/php81/usr/bin/php -q /home/myusername/public_html/cron.php
6. Add the Cron Job:
Click on the "Add New Cron Job" button after entering the command. You should see a confirmation message indicating that your cron job has been successfully created.
7. Test Your Cron Job:
To ensure that your cron job works, you can run the command manually or check the output in your email, if configured to send notifications.
8. Example Command:
Here’s a complete example command for running a cron job using PHP 8.1:
/opt/alt/php81/usr/bin/php -q /home/myusername/public_html/cron.php
Make sure to replace myusername
with your actual cPanel username and adjust the PHP version according to your needs.
For more information about our web hosting services, visit DOScast Web Hosting. Plans start at just $2.08 per month!
If you require assistance, please reach out to our technical support team via this link.