CRON tasks are automated jobs scheduled to run in Unix-based operating systems. Cron is a program used for planning and executing specific tasks at defined intervals, such as every minute, every hour, daily, etc.
You can set up a CRON job in cPanel under the Cron Jobs section.
There, you have the option to set the time for the task to run and specify the command.
To execute any file on the account through a CRON job, you can use one of two methods. You can execute a CRON job using a browser link to the file (Method 1) or by utilizing a selected PHP version along with the file path from the user account (Method 2).
Method 1:
To use a CRON job that triggers a script via a link, use the following command:
wget -q -O /dev/null [address] > /dev/null 2>&1
The -O
option allows specifying the path for writing (using /dev/null
ensures the file is not saved). The -q
option prevents logging the operation. /dev/null 2>&1
redirects to the void, meaning no email notification will be sent about the CRON job execution. Replace [address] with the full link to the page to be called.
For regularly executed tasks, it is recommended to use > /dev/null 2>&1
to avoid filling the disk space with notifications.
Method 2:
To execute a CRON command through PHP, use the following command:
/opt/cpanel/ea-php74/root/usr/bin/php /home/username/file_to_execute > /dev/null 2>&1
In this case, provide the full path to the file and the PHP version to be used. In the example above, PHP version 7.4 is used.
- Free SSL certificates at smarthost.au and DNS zone at a third-party provider - October 3, 2024
- How to install an EV certificate? - October 3, 2024
- How do SSL certificates work? What are the types of SSL certificates? - October 3, 2024