|
Search |
Linux distributions allow you to configure your scripts so that they are executed for a given time period or at certain hour/day. Configuring a Cron task The main configuration file for cron, /etc/crontab, contains the following lines:: SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # run-parts 01 * * * * root run-parts /etc/cron.hourly 02 4 * * * root run-parts /etc/cron.daily 22 4 * * 0 root run-parts /etc/cron.weekly 42 4 1 * * root run-parts /etc/cron.monthly The first four lines are variables used to configure the environment in which the cron tasks are run. The value of the SHELL variable tells the system which shell environment to use (in this example the bash shell), and the PATH variable defines the path used to execute commands. The output of the cron tasks are emailed to the username defined with the MAILTO variable. If the MAILTO variable is defined as an empty string (MAILTO=""), email will not be sent. The HOME variable can be used to set the home directory to use when executing commands or scripts. Each line in the /etc/crontab file has the format: minute hour day month dayofweek command
For any of the above values, an asterisk (*) can be used to specify all valid values. For example, an asterisk for the month value means execute the command every month within the constraints of the other values. A hyphen (-) between integers specifies a range of integers. For example, 1-4 means the integers 1, 2, 3, and 4. A list of values separated by commas (,) specifies a list. For example, 3, 4, 6, 8 indicates those four specific integers. The forward slash (/) can be used to specify step values. The value of an integer can be skipped within a range by following the range with / Any lines that begin with a hash mark (#) are comments and are not processed. How to start an automatic execution of a script on hosting plan? First it needs to be verified whether the script works in shell mode. In order to do it you need to place #!/usr/local/bin/php, for php script, #!/usr/bin/perl, for perl, lub #!/bin/bash, for shell script. Then use chmod 700 skrypt.cgi command for the script. If you have telnet/ssh access you may check it by./script.cgi. Remember to use cd /home/login command at the beginning of the script. You may use absolute path to indicate the file. After verification of the script in shell mode, you need to contact Client Service Panel by email and provide the following data:
|