Shell-crontab quick manual cron is a UNIX tool that uses cron background processes to automatically execute tasks at specific times in the future. These tasks are usually called cron jobs. crontab is one of the cron records to be run at a specific time. crontab restriction: If your name appears in/usr/lib/cron. allow, You can execute crontab. if the file does not exist, and your name is not in/usr/lib/cron. deny appears. You can also use crontab. if only cron. deny exists and is an empty file, so all users can use crontab. if both files do not exist, only root users can use crontab. one user name per line of the all/deny file. Www.2cto.com 2. crontab command: First, you must specify an editor to open the crontab file. Generally, you can use vi. crontab-e to edit your crontab file or create one if it does not exist. Crontab-l: displays your crontab file. Crontab-r: delete your crontab file. 3. crontab File Syntax: ***** command to be executed--| + ----- day of week (0-6) (Sunday = 0) | + ------- month (1-12) | + --------- day of month (1-31) | + ----------- hour (0-23) + ------------- min (0-59) * in the value Field above indicates all valid values in the column brackets. The value column can be a * or a group of elements separated by commas. The elements of all columns are either a number in the preceding range or two numbers in the preceding range separated by the delimiter (-) (representing a left-right closed domain ). Date can be specified in two domains: month day and week day. If both are specified in one record, they are the cumulative effect of the two records. Www.2cto.com 4. in the crontab example, a column in the crontab file is removed from/home/someuser/tmp: 30 18 * rm/home/someuser/tmp/* changing the parameters shown below will make the Command run according to different time plans: minhourday/monthday/week Execution time30011, at on May 12, January, June, and May 1, December, www.2cto.com 020*101-510 every Business Day (Monday to Friday) is executed, 15 ** execute 5, * 1 at midnight on day 1, 10, and 15, every Monday and day 10 of every month at and. the Crontab environment cron uses/usr/bin/sh to call the command from the user's HOME directory. Cron provides a default environment for each shell, which is defined as follows: HOME = user's-home-directory LOGNAME = user's-login-id PATH =/usr/bin: /usr/sbin :. SHELL =/usr/bin/sh if the user wants them. if profile is executed, it must be explicitly executed in the crontab command script, or in a separate script, it is called by the crontab command script. 6. Disable Email the information output to the screen under the command line will be written into mail when crontab is used. If not, place the following command at the end of cronjob line of crontab. Www.2cto.com remarks: when running a program using>/dev/null on UNIX, the output from the program to stdout can be blocked. However, if the program also outputs to stderr, the information output to stderr is still displayed on the screen. A common method to shield stderr is to use pipelines to output stderr to stdout and stdout to/dev/null. It is generally written as follows: proc>/dev/null 2> & 1. this method is only applicable to the sh environment. If it is in another shell environment, such as csh, "Ambiguous output redirect.. Fortunately, the default shell of crontab is sh. 7. the principle of log file generation is the same as that of log file 6. You can redirect it to the file:>/home/someuser/cronlogs/. log 2> & 1