CronTab task cycle plan in CentOS

Source: Internet
Author: User
CronTab task schedule format: ***** command score (0-59), hour (0-23), Day (1-31), month (1-12) week (0-6) description: 1. asterisks can match all characters 2, an integer, must be exact match 3, two integers separated by a short line, they match the value range. 4. add a diagonal slice and a step value after the time range. 1-10/2 general user process: crontab-ecrontab is set with setuid, so the user has

CronTab task schedule

Format:
* *** Command points (0-59), hour (0-23), Day (1-31), month (1-12), Week (0-6)
Note:
1. asterisks can match all characters. 2. an integer. must be precisely matched. 3. two integers separated by short dashes. they match the value range. 4. add a diagonal slice and a step value after the time range. 1-10/2
Common User process: crontab-e crontab is set with setuid, so the user has his or her permissions, that is, root, and will go to/tmp/cron .... after the file is processed, it is saved in/var/spool/cron/$ username. Log:/var/log/cron configuration Directory:/var/run/crond. pid process ID address/etc/crontab instruction file/etc/$ weekday. you can put the script in the directory of the hour, day, month, and week, and execute the script on time. /Etc/cron. {deny, allow} rejects and allows users to use crontabVixie-Cron: This package is installed by default during centos installation. this package can include a step value. That is, for example, 1, 3, 6, 9, 12 can be written as, 1-12/3 divided by 3. The so-called */1 */2 means that the command is run every two minutes every minute. That is, 1-59/{2, 3 }. % Indicates the line feed in the command. only the text before the first percent is included in the actual command, and other lines are used as the standard input for this command. Install: yum install-y crontabs:
Crontab -- helpcrontab-e # check out a copy of crontab, call vi to edit it, and save the crontab directory again. Crontab-l # print the content of crontab to the standard output. Crontab-r # No content is left in the volume.
... Root, except for other users. Crontab-r $ username
[Root @ nagios ~] # Crontab -- helpcrontab: invalid option -- '-' crontab: usage error: unrecognized optionusage: crontab [-u user] filecrontab [-u user] [-e |-l |-r] (default operation is replace, per 1003.2)-e (edit user's crontab) -l (list user's crontab)-r (delete user's crontab)-I (prompt before deleting user's crontab)-s (selinux context) [root @ nagios ~] # Ll/usr/bin/crontab

-Rwsr-xr-x 1 root 47520 Jul 19 2011/usr/bin/crontab

[Root @ nagios ~] # Cat/var/run/crond. pid 2074 [root @ nagios ~] # Ll/etc/| grep-E crondrc WXR-xr-x 2 root 4096 Apr 2 cron. ddrwxr-xr-x. 2 root 4096 Sep 27 2011 cron. daily-rw-r -- 1 root 0 Jul 19 2011 cron. denydrwxr-xr-x 2 root 4096 Sep 27 2011 cron. hourlydrwxr-xr-x 2 root 4096 Sep 27 2011 cron. monthly-rw-r -- 1 root 457 Sep 27 2011 crontabdrwxr-xr-x 2 root 4096 Sep 27 2011 cron. weekly [root @ nagios ~] # Cat/etc/crontab SHELL =/bin/bashPATH =/sbin:/bin:/usr/sbin: /usr/binMAILTO = rootHOME =/# For details see man 4 crontabs # Example of job definition :#. ---------------- minute (0-59) # |. ------------- hour (0-23) # |. ---------- day of month (1-31) # |. ------- month (1-12) OR jan, feb, mar, apr... # |. ---- day of week (0-6) (Sunday = 0 or 7) OR sun, mon, tue, wed, thu, fri, sat # ||| #* * *** User-name command to be executed [root @ nagios ~] # Ll/var/spool/cron/total 8-rw ------- 1 root 60 Apr 2 0:33 root-rw ------- 1 zwhset 68 Apr 2 0:51 zwhset [root @ nagios ~] # Tail-5/var/log/cron Apr 2 17:24:01 nagios CROND [20544]: (root) CMD (/bin/sh ~ /Hello) Apr 2 17:25:01 nagios CROND [20549]: (root) CMD (/bin/sh ~ /Hello) Apr 2 17:25:01 nagios CROND [20550]: (root) CMD (/bin/sh ~ /Hello) Apr 2 17:25:01 nagios CROND [20551]: (zwhset) CMD (echo "hello" >> ~ /1.txt) Apr 2 17:25:01 nagios CROND [20552]: (zwhset) CMD (echo "hello" >>> ~ /1.txt)


[Root @ nagios ~] # Ps aux | grep cron

Root 2074 0.0 0.5 117212 1316? Ss crond

Root 20641 0.0 0.6 139684 1468 pts/1 S + crontab-e

Zwhset 20642 0.0 0.7 119284 pts/1 S +/bin/vi/tmp/crontab. YphQpH

Root 20663 0.0 0.3 103236 856 pts/0 S + grep cron

[Root @ nagios ~] # Lsof-c crontab

Command pid user fd type device size/OFF NODE NAME

Crontab 20641 root cwd DIR 253,0 4096 130818/root

Crontab 20641 root rtd DIR 253,0 4096 2/

Crontab 20641 root txt REG 253,0 47520 401259/usr/bin/crontab

Crontab 20641 root mem REG 253,0 5952 261889/lib64/security/pam_deny.so

Crontab 20641 root mem REG 253,0 18592 261891/lib64/security/pam_env.so

Crontab 20641 root mem REG 253,0 18592 261903/lib64/security/pam_limits.so

Crontab 20641 root mem REG 253,0 10224 261901/lib64/security/pam_keyinit.so

Crontab 20641 root mem REG 253,0 10240 261906/lib64/security/pam_loginuid.so

Crontab 20641 root mem REG 253,0 6040 261912/lib64/security/pam_permit.so

Crontab 20641 root mem REG 253,0 14384 261923/lib64/security/pam_succeed_if.so

Crontab 20641 root mem REG 253,0 10200 261905/lib64/security/pam_localuser.so

Crontab 20641 root mem REG 253,0 51952 261929/lib64/security/pam_unix.so

Crontab 20641 root mem REG 253,0 113432 261657/lib64/libnsl-2.12.so

Crontab 20641 root mem REG 253,0 14456 261884/lib64/security/pam_access.so

Crontab 20641 root mem REG 253,0 65928 261663/lib64/libnss_files-2.12.so

Crontab 20641 root mem REG 253,0 99158576 397021/usr/lib/locale-archive

Crontab 20641 root mem REG 253,0 383504 261640/lib64/libfreebl3.so

Crontab 20641 root mem REG 253,0 40400 261651/lib64/libcrypt-2.12.so

Crontab 20641 root mem REG 253,0 1916568 261647/lib64/libc-2.12.so

Crontab 20641 root mem REG 253,0 113096 261709/lib64/libaudit. so.1.0.0

Crontab 20641 root mem REG 253,0 19536 261653/lib64/libdl-2.12.so

Crontab 20641 root mem REG 253,0 55848 261879/lib64/libpam. so.0.82.2

Crontab 20641 root mem REG 253,0 122040 261718/lib64/libselinux. so.1

Crontab 20641 root mem REG 253,0 154464 261636/lib64/ld-2.12.so

Crontab 20641 root 0u CHR 136,1 0t0 4/dev/pts/1

Crontab 20641 root 1u CHR 136,1 0t0 4/dev/pts/1

Crontab 20641 root 2u CHR 136,1 0t0 4/dev/pts/1

Crontab 20641 root 3u unix 0xffff88000225c380 0t0 91831 socket

Crontab 20641 root 5u REG 253,0 68 916745/tmp/crontab. YphQpH


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.