1. Introduction to the crontab Environment1. cron service in/etc/init. d/cron2. run the/usr/sbin/cron3. cron configuration file in/etc/cron. dfile list :. PROTO, FIFO,. deny, cron. allow, cron. deny, queuedefs4. cron connection file/usr/lib/cron/-> .. /.. /etc/cron. d5. the user's crontab file is located in the/usr/spool/cron/crontabs directory and named after the user name.
2. Start and Stop the crontab service.CD/etc/init. d./cron stop./cron start
3. crontab command descriptionCrontab-L: list the crontab files of the current user. Crontab-l Username: Used to list crontab files of a specified user. (Root User) crontab-E: edit the crontab file of the current user. Crontab-e Username: edit the crontab file of the specified user. (Root User) crontab-R: Delete the crontab file of the current user. Crontab-r username: Delete the crontab file of the specified user. (Root User)
4. crontab syntax descriptionSyntax format of the crontab file. Each line of statements is *** command, which indicates a task and can contain multiple statements. The first * field: 0 ~ 59 indicates the score
Second * field: 1 ~ 23 indicates the hour
Third * field: 1 ~ 31 indicates the day
Fourth * field: 1 ~ 12 indicates the month.
Fifth * field: 0 ~ 6 indicates the Fifth Command Field in the week (0 indicates Sunday): If you want to execute a command once every 20 minutes, you can write it like this:
To execute a task at, 40 *** command every five minutes, you can write it as follows:
0, 5, 10, 15, 20, 25, 30, 35, 40, 4, 50, 55 *** command to execute a task every minute, you can write it as follows: the crontab in 0-59 *** commandsolaris is different from that in Linux.
*/5 indicates every 5 minutes
*/20 indicates every 20 minutes
Solaris does not support
5. crontab editor settingsIf no editor is set, crontab-E calls the default editor. Set Editor: Export editor = vim, and then call crontab-e.
6. Examples1. export editor = vim2. crontab-E, add: 0-59 *****/export/home/Netcool/cron_test.sh to the file, save it, and exit (: WQ) 3. VI/export/home/Netcool/cron_test.shecho "AAA">/export/home/Netcool/cron_test.logchmod A + x/export/home/Netcool/cron_test.sh4. restart the service CD/etc/init. d /. /cron stop PS-Ef | grep cron to check whether the Stop command exists. You can run the Stop command multiple times. /cron start
7. Solution to non-execution of crontab
1.1. Make sure that the path for executing the script is correct. It is best to use the full path.
1.2. Make sure that the environment variables are correctYou can set the $ home/. Profile environment variable in shell. You can add an environment variable script in shell, such as e.g.: Export omnibus_home =/opt/Netcool/omnibus.
1.3. Permission issuesAdd the current user to/etc/cron. d/cron. allow, and ensure that no current user exists in/etc/cron. d/cron. deny. If no cron. allow file exists, use the root user to create the file.
1.4. FIFO Problems1. First kill the cron process. You can use PS-Ef | grep cron to get the ID number, kill-9 pid2. RM/etc/cron. d/fifo3../cron start