Using automated tasks on a Web Hosting plan
Find out how to configure scheduled jobs on your Web Hosting
Find out how to configure scheduled jobs on your Web Hosting
Last updated 1st December 2022
On OVHcloud Web Hostings, you can use scripts to automate certain operations. Creating a scheduled task ("cron job") is the easiest way to ensure your scripts are running at specific times without further actions necessary on your part.
This guide explains how to create cron jobs to automate scheduled tasks on a Web Hosting.
OVHcloud is providing you with services for which you are responsible, with regard to their configuration and management. You are therefore responsible for ensuring they function correctly.
This guide is designed to assist you in common tasks as much as possible. Nevertheless, we recommend contacting a specialised provider and/or the software publisher for the service if you encounter any difficulties. We will not be able to assist you ourselves. You can find more information in the “Go further” section of this guide.
Log in to your OVHcloud Control Panel and select
Web Cloud in the top navigation bar. Click
Hosting plans, then choose the Web Hosting plan concerned. Next, navigate to the
cron tab by selecting it in the
In this section you will see an overview of your scheduled jobs and their settings.
To create a new cron task, click on the
Add a scheduling button on the right-hand side. You can customise the settings for the task in the new window.
|Command to be executed||Define the path to the file containing your script. Example: www/jobs/cron.php|
|Language||Select the PHP version the script is using.|
|Activation||Choose whether the task will be active after creation or activated later.|
|Logs by email||If necessary, select a contact (admin or technical) to whom a report will be sent in case of an execution error. You can also provide an alternative email address.|
|Description||Enter a description to keep track of what your tasks do.|
Next to proceed to the second step.
The interface offers two modes to configure the frequency of your task. Use the Basic mode for a beginner-friendly selection of scheduling options. If you prefer to directly enter a frequency, similar to a cron table format (crontab), choose the Advanced mode.
|Use the drop-down menus to specify the time of day, days of a month, week days and months for the task.|
|Enter numeric values as you would in a crontab. The asterisk operator denotes "every value" of the time period, meaning the task would continuously run once an hour every day in this example.|
You can switch between the two modes during configuration to view the changes accordingly. Please also note the limitations when scheduling a task on a Web Hosting.
The summary lists all your settings including the crontab notation of the execution frequency. If everything is correct, click on
The task will be ready within a few minutes. You can then modify all of its settings or delete the task by clicking on
... in the overview table in your OVHcloud Control Panel.
|Hourly scheduling||You might notice that the field for "Minutes of the hour" is disabled in the interface (set to "?" in the crontab view). A task can only be executed once an hour as the highest repetition frequency and the minute of execution cannot be specified.|
|Running time||The time limit for a task is 60 minutes. If a script exceeds this running time, it will be stopped automatically by the system.|
|Variables||You can only define variables in a script. Adding them to the URL calling the script will not work (Example: www/jobs/cron.php?variable=value).|
|Data limit||A task can only generate up to 5 MB of data (stdin/stderr). For example, if a script writes data into a .txt file, the execution will be stopped automatically once the file reaches 5 MB in size.|
|Scripts producing errors||If a script is faulty, it will be automatically disabled after 10 failed execution attempts. Simply re-activate it in the Control Panel. (Click on
|Execution reports||Reports will be sent to your selected email address only once a day (during night hours).|
A simple test to see if your script will produce an error is to run it in a web browser. For example, if the file path of your script is "www/cron.php" and your hosting domain is "mypersonaldomain.ovh", you would use the URL "http://mypersonaldomain.ovh/cron.php". If no error is showing up but the script is not performing as expected, follow up with the suggestions below.
Always make sure to use absolute paths to files in your scripts. The "DIR" constant, for example, can help to receive the current path in PHP scripts (PHP documentation).
In your Web Hosting's logs, accessible from the OVHcloud Control Panel, you will see the log category labelled "cron".
Please refer to this guide for details.
[2020-08-11 00:36:01] ## OVH ## START - 2020-08-11 00:36:01.524384 executing: /usr/local/php7.2/bin/php /homez.161/myftpusername/www/myscript.sh [2020-08-11 00:36:01] [2020-08-11 00:36:01] ## OVH ## END - 2020-08-10 22:39:44.086166 exitcode: 0
[2020-08-11 00:36:01] ## OVH ## START - 2020-08-11 00:36:01.524384 executing: /usr/local/php7.2/bin/php /homez.161/myftpusername/www/sleep.sh [2020-08-11 01:36:01] ## OVH ## ERROR - CRON TASK INTERRUPTED BY OVH - reason: your script duration exceeded the maximum permitted (3600 seconds) [2020-08-11 01:36:01] ## OVH ## END - 2020-08-11 01:36:01.086166 exitcode: 0
[2020-08-11 00:36:01] ## OVH ## START - 2020-08-11 00:36:01.524384 executing: /usr/local/php7.2/bin/php /homez.161/myftpusername/www/noscript.sh [2020-08-11 00:36:01] ## OVH ## ERROR command '/homez.161/myftpusername/www/noscript.sh' not found [2020-08-11 00:36:01] ## OVH ## END - 2020-08-11 00:36:01.086166 exitcode: 255
[2020-08-11 18:07:10] ## OVH ## Your job could not be initiated for an unknown reason. [2020-08-11 18:07:10] [2020-08-11 18:07:10] ## OVH ## END - 2020-08-11 18:07:10.969840 exitcode: 255
Join our community of users on https://community.ovh.com/en/.
Please feel free to give any suggestions in order to improve this documentation.
Whether your feedback is about images, content, or structure, please share it, so that we can improve it together.
Your support requests will not be processed via this form. To do this, please use the "Create a ticket" form.
Thank you. Your feedback has been received.
Access your community space. Ask questions, search for information, post content, and interact with other OVHcloud Community members.Discuss with the OVHcloud community