CRON Jobs β Scheduling PHP Scripts on the Server
CRON allows you to periodically run PHP scripts on the server side.
You can add CRON jobs in cPanel under:
βcPanelβ β βADVANCEDβ β βCron jobsβ
Examples:
Option 1 β CRON job triggered via web:
/usr/bin/wget -q -O /dev/null http://yourdomain.ee/file.php
If you want the script to run silently, add -q -O /dev/null
to the command line (as shown above). Otherwise, wget will send email reports with the results.
-q
= quiet mode-O
= output (requires an argument, e.g., /dev/null
)Option 2 β CRON job using PHP directly:
1. Using the server’s default PHP version:
/usr/local/bin/php /home/yourusername/domains/yourdomain.ee/public_html/file.php
2. Using a specific PHP version you defined:
/usr/local/bin/php -ea_php 83 /home/yourusername/domains/yourdomain.ee/public_html/file.php
3. Using a specific PHP version with a custom php.ini file:
/usr/local/bin/php -ea_php 83 -c /home/yourusername/domains/yourdomain.ee/public_html/php.ini /home/yourusername/domains/yourdomain.ee/public_html/file.php
(Replace 83
with your desired PHP version. Make sure there’s a space between php
and /home/...
)
Use full (absolute) file paths in scripts executed via CRON.
Reports about the success or failure of CRON jobs are sent to the main userβs mailbox (e.g., np*****
or r******
).
Once the CRON job works properly, we recommend disabling the email reports to avoid overloading your main accountβs mailbox. If errors occur, check the email report for details.
You can log in to the main user’s mailbox using standard webmail access. Use your cPanel username (main account) as the login.
NB! There are no strict limitations on CRON job frequency, but best practice suggests running them no more than once every 15 minutes.