This article is intended to help you differentiate between Wget client, Curl and PHP commands.
To see the differences, let’s start by looking at the following four commands:
wget -O - -q 'https://www.planethoster.net/modules/cron.php?secure_key=ILOVEPH' --user-agent="PlanetHoster/CRON" > /dev/null 2>&1
curl --user-agent "planethoster" https://www.planethoster.net/modules/cron.php
php -q /home/USERNAME/public_html/modules/cron.php argument=valeur >/dev/null 2>&1
The most important difference is that both Wget and Curl use the HTTP protocol. Therefore, Apache configurations or restrictions are added. The Apache timeout is a good example.
Different Versions of PHP and Cron Tasks
If you leave the “php” command as is, the task will use the native/recommended version defined in the WHM (MultiPHP Manager) control panel. If your script needs to use another version of PHP, you must specify this by giving the full path to PHP.
For example, for World cPanel CloudLinux and HybridCloud cPanel Cloudlinux, you should use this command, where XX should be replaced with the desired PHP version between php56, php70, php71, php72 and php73 :
For non-CloudLinux HybridCloud cPanel, use this command, where XX must be replaced by the desired PHP version between php56, php70, php71, php72 and php73 :
For N0C, use this command, where XX must be replaced by the desired PHP version between php44, php51, php52, php53, php54, php55, php56, php70, php71, php72, php73, php74, and php80 :
1-When you launch a Cron with the Curl or Wget command, you must absolutely specify a “user-agent” as in the example above. Otherwise, it is possible that your request is blocked at the server level because of the ModSecurity web application firewall.
2- We also advise you not to run the script every minute. It is better to run it during the night.
3- If you receive too many emails from Cron tasks, you can disable this notification by adding this at the end of your task:
4- If you have “GET” arguments to give to your script, you should not separate the file argument with a “?”. You simply need to put a space.