For Linux Web Hosting packages and Managed Dedicated Server

Cronjobs are practical when it comes to automating recurring tasks, but they can also affect the function of the website if used improperly. In this article you will learn what to look out for when creating and executing cronjobs.

If you consider the following points, the smooth execution of your cronjobs should be guaranteed:

  • Allow a minimum of 5 minutes to elapse before repeating a cron job. This prevents your cronjobs from running in parallel and thus slower at times of high server load.

  • Always add an MAILTO (e.g.: MAILTO=john.smith@example.com) to the top of your Crontab file. This allows you to receive the specific error message conveniently by email.

  • You can call a PHP script using the following binaries:

    /usr/bin/php4.4 (/usr/bin/php and /usr/bin/php4 are symlinks)
    /usr/bin/php5.2 (/usr/bin/php5 is a symlink) 
    /usr/bin/php5.4 
    /usr/bin/php5.5 
    /usr/bin/php7.1
    /usr/bin/php7.2
    /usr/bin/php7.3
    /usr/bin/php7.4
    /usr/bin/php8.0
    /usr/bin/php8.1
    /usr/bin/php8.2

    Example:

*/10 * * * * /usr/bin/php8.2 -f /homepages/12/d12345678/htdocs/test.php
  • Pay attention to the full path.
  • For PHP scripts executed by a cron job, a stored php.ini is ignored. This means that any changed variables are not set. Alternatively, you can run the PHP script using an HTTP request:
*/10 * * * * /usr/bin/curl -s https://example.com/test.php > /dev/null

If the script is in a protected directory, you must pass the access data using the parameter -u.
For shared hosting packages, we recommend that you always protect the directory with directory protection.

*/10 * * * /usr/bin/curl -s -u user:password https://example.com/test.php > /dev/null