Cronjobs are used to automate recurring tasks. You can control the times and/or days on which certain programs or scripts are executed. To create a new cronjob, log into your Control Panel.
The Cronjob Manager is found under Admin.
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/beispiel.php >/dev/null 2>&1
/home/username/bin/beispiel >/dev/null 2>&1
The file you want to execute as a cronjob must either be executable or able to be executed by an interpreter.
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.
This special line in the script specifies the interpreter that can read and execute the contents of this script. It is always the topmost 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:
Additional shebang lines:
Note: Make sure that you do not use any DOS line breaks!
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 system paths.
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/beispiel.php
Other command lines:
Um zu bestimmen, wann das Kommando des Cronjobs ausgeführt werden soll, müssen Sie fünf Zeitwerte angeben. Der Cron-Daemon prüft minütlich, ob einer Ihrer Cronjobs ausgeführt werden soll. Immer wenn alle fünf Werte zutreffen, wird das Kommando ausgeführt.
You can also specify multiple comma-separated values. To start a job at xx:20 and xx:50, enter ‘20,50’ for ‘Minute’
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”.
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.
If possible, we recommend starting your cronjob at night between the hours of 1:00 am and 5:00 am, because the server load is less at these times than during the day or at midnight.
To execute a script for a weekly summary every Saturday night at 23:15:
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.
/usr/local/bin/php -f /home/username/bin/checkmail.php
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.
/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 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.