Select your language

Cronjobs are used to automate recurring tasks. You can control the times and/or days on which certain programs or scripts are executed.

Create cronjob

To create a new cron job, log in to your Control Panel. You will find the Cronjob Manager on the server overview under «Advanced».

Notifications

If your cronjob generates text output when executed, this text will be sent to you by E-Mail.

You can specify a recipient address for the messages in the E-Mail address field. If you do not want these notifications, add the string >/dev/null 2>&1 at the end of your command to disable all output.

/usr/local/bin/php -f /home/username/bin/example.php >/dev/null 2>&1

or

/home/username/bin/example >/dev/null 2>&1

Cronjob command

The file you want to execute as a cronjob must either be executable or able to be executed by an interpreter.

Executable files

Binary programs or scripts with a shebang line can be executed directly.

Here you should make sure that the file mode allows this as well: The x-bit must be set. If you are unsure, set the mode to 755 or 750.

Shebang line

This special line in the script specifies the interpreter that can read and execute the contents of this script.

It is always the top line in the first column and it begins with the symbols #!, followed by the path to the interpreter.

A shebang line for a PHP script on our FreeBSD servers looks like this:

#!/usr/local/bin/php

Additional shebang lines:

#!/usr/local/bin/perl
#!/usr/local/bin/python

Starting scripts with an interpreter

To execute a script without a shebang line, you must invoke it with the appropriate interpreter.

Note that most additional programs running on FreeBSD Unix are found under /usr/local/bin/.

For information on this topic, refer to the article on paths, directories, system.

The cron command for a PHP script located in /home/username/bin/example.php looks like this:

/usr/local/bin/php -f /home/username/bin/example.php

Other command lines:

/usr/local/bin/perl /home/username/bin/example.pl
/usr/local/bin/python /home/username/bin/example.py

Time of execution

Five values have to be defined to determine the time of execution of a cronjob. Every minute, the cronjob daemon checks these values and will execute the cronjob when all five values are met.

Minute
Enter the minute in which you want your cronjob to be executed (0-59).
Hour
Enter the hour in which you want your cronjob to be executed (0-23).
Day
Enter the day of the month on which you want your cronjob to be executed (1-31).
Month
Enter the month of the year on which you want your cronjob to be executed (1-12).
Weekday
Enter the day of the week on which you want your cronjob to be executed (0-6, Sunday is 0 and 6 is Saturday).

List

You can also specify multiple comma-separated values. To start a job at xx:20 and xx:50, enter "20,50" for "Minute".

Wildcard

You can use a wildcard (*) for fields that you want to ignore. If, for example, you want to execute a job on every day of the year, you do not have to enter every possibility for «Day», «Month» and «Weekday». It is sufficient to complete these fields with an «*», which means “always true”.

Interval

If you want to execute a script at a specific interval, indicate this with "*/interval". The field is considered true if the current value is completely divisible by the interval. If you want a job to be executed every two hours, enter */2 for Hour. This will be true for 0, 2, 4, 6 o’clock, etc.

Examples

Executing at a specific time

To execute a script for a weekly summary every Saturday night at 23:15:

Minute: 15
Hour: 23
Day: *
Weekday: 6
Month: *

Command:

/home/username/bin/summary.pl

Execute every 5 minutes

You allow your website users to upload a picture of themselves to the website via E-Mail. For this purpose, you want to check this mailbox every five minutes for new pictures to add to the site.

Minute: */5
Hour: *
Day: *
Weekday: *
Month: *

Command:

/usr/local/bin/php -f /home/username/bin/checkmail.php

Repeated execution at night

To create a short movie, you want to download a nighttime picture of your city from a webcam at regular intervals. To do so, you have written a “one-liner” script that you want to execute every 20 minutes between the hours of 20:00 and 6:00 in the morning.

Minute: */20
Hour: 20-23,0-6
Day: *
Weekday: *
Month: *

Command:

/usr/local/bin/wget 'http://www.example.com/webcam.cgi?tilt=-20&yaw=93' -O /home/username/cam-images/`date +\%Y-\%m-\%d`.jpg

You can also periodically request a URL without downloading the file:

/usr/local/bin/wget -q -O /dev/null 'http://www.exmaple.com/cron.php' >/dev/null 2>&1

Additional resources

Additional information about working with cronjobs can be found here: http://www.howtoforge.de/anleitung/e...-in-cron-jobs/ or by referring to your preferred Unix guide.

Please use this form only to provide feedback on the above guide.
For support requests please use this form instead.

 

 

© 2001 - Hostpoint AG
Cookie

Wir verwenden Cookies  🍪

We use Cookies  🍪

Nous utilisons des cookies  🍪

Utilizziamo dei cookie  🍪

Die digitalen Auftritte von Hostpoint (Website, Control Panel, Support Center etc.) verwenden Cookies. Diese werden dazu verwendet, um Daten über Besucherinteraktionen zu sammeln. Wenn Sie auf «Akzeptieren» klicken, stimmen Sie der Verwendung dieser Cookies für Werbezwecke, Website-Analyse und Support zu. Gewisse essenzielle Cookies sind jedoch für eine ordnungsgemässe Funktion dieser Seiten unerlässlich und können deshalb nicht deaktiviert werden. Auch ohne Ihre Zustimmung können gewisse Daten in anonymisierter Form für statistische Zwecke und zur Verbesserung unserer Websites verwendet werden. Bitte beachten Sie unsere Datenschutzerklärung.

Hostpoint's digital presences (website, Control Panel, Support Center, etc.) use cookies. These are used to collect data on visitor interactions. If you click “Accept”, you agree to the use of these cookies for advertising purposes, website analysis and support. However, certain cookies are essential for the proper functioning of these pages and therefore cannot be disabled. Even without your consent, certain data may be used in anonymized form for statistical purposes and to improve our websites. Please note our Privacy policy.

Le sites Web de Hostpoint (site Web, Control Panel, Centre d'assistance, etc.) utilisent des cookies. Ces cookies servent à collecter des données sur les interactions des visiteurs. En cliquant sur «Accepter», vous consentez à l’utilisation de ces cookies à des fins de publicité, d’analyse du site Web et d’assistance. Certains cookies essentiels sont cependant indispensables au bon fonctionnement de notre sites Web et ne peuvent donc pas être désactivés. Même sans votre consentement, certaines données peuvent être utilisées sous forme anonymisée à des fins statistiques et pour améliorer notre sites Web. Veuillez prendre connaissance de notre Déclaration de protection des données.

Le presenze digitali di Hostpoint (sito web, Pannello di controllo, Support Center, ecc.) utilizzano i cookie. Questi vengono utilizzati per raccogliere dati sulle interazioni dei visitatori. Facendo clic su «Accetta», acconsente all’utilizzo di questi cookie per scopi pubblicitari, di analisi del sito web e di supporto. Alcuni cookie essenziali sono tuttavia indispensabili per il corretto funzionamento di questi siti web e pertanto non possono essere disattivati. Anche senza il Suo consenso, determinati dati potrebbero essere utilizzati in forma anonima per fini statistici e per l’ottimizzazione dei nostri siti web. Si prega di tenere conto della nostra Dichiarazione per la pivacy.

Ablehnen
Decline
Refuser
Rifiuta
Akzeptieren
Accept
Accepter
Accetta