In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what are the aspects of the CronTab task cycle under CentOS". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what are the aspects of the CronTab task cycle under CentOS"?
CronTab task cycle planning
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 match exactly
3. Two integers separated by dashes match the range of values.
4. Add oblique carrying and a step value after the time range. 1-10 Band 2
General user process:
Crontab-e crontab is set to setuid, so the user has his permission, that is, root, and will be in / tmp/cron.... The file is saved in / var/spool/cron/$username after processing.
Log:
/ var/log/cron
Configuration directory:
/ var/run/crond.pid process number address
/ etc/crontab usage guidance file
/ etc/$weekday. Wait for the directory of the day, moon and week when parting, that is, you can put the script into it and he will execute it on time.
/ etc/cron. {deny,allow} deny and allow users to use crontab
Vixie-Cron:
This package is installed by default when centos is installed, and it can include a step value. That is, for example, 1, 3, 6, 6, 9, 12, 12 can be written, 1-12 stroke 3 divided by 3. The so-called * / 1 * / 2 is to run command every two minutes. That is, 1-59 / {2pr 3}.
The use of% sign:
The% percent sign indicates a line break in command, only the text before the first percent sign is included in the actual command, and the rest of the lines are used as standard input for the command.
Installation:
Yum install-y crontabs
Use:
Crontab-help
Crontab-e # checks out a copy of crontab, calls vi to edit it, and re-saves it in the crontab directory.
Crontab-l # prints the contents of crontab to standard output.
The crontab-r # book does not leave anything except.
.
The root book excludes other users.
Crontab-r $username
[root@nagios] # crontab-- help
Crontab: invalid option -'-'
Crontab: usage error: unrecognized option
Usage:crontab [- u user] file
Crontab [- 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 root 47520 Jul 19 2011 / usr/bin/crontab
[root@nagios ~] # cat / var/run/crond.pid
2074
[root@nagios ~] # ll / etc/ | grep-E cron
Drwxr-xr-x 2 root root 4096 Apr 2 00:59 cron.d
Drwxr-xr-x. 2 root root 4096 Sep 27 2011 cron.daily
-rw-r--r-- 1 root root 0 Jul 19 2011 cron.deny
Drwxr-xr-x 2 root root 4096 Sep 27 2011 cron.hourly
Drwxr-xr-x 2 root root 4096 Sep 27 2011 cron.monthly
-rw-r--r-- 1 root root 457 Sep 27 2011 crontab
Drwxr-xr-x 2 root root 4096 Sep 27 2011 cron.weekly
[root@nagios ~] # cat / etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# 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 root 60 Apr 2 01:33 root
-rw- 1 zwhset zwhset 68 Apr 2 01: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 01:40 0:04 crond
Root 20641 0.0 0.6 139684 1468 pts/1 S + 17:30 0:00 crontab-e
Zwhset 20642 0.00.7 119284 1756 pts/1 S+ 17:30 0:00 / bin/vi / tmp/crontab.YphQpH
Root 20663 0.00.3 103236 856 pts/0 S+ 17:31 0:00 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/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
Thank you for your reading, the above is the content of "what are the aspects of the CronTab task cycle under CentOS". After the study of this article, I believe you have a deeper understanding of what aspects of the CronTab task cycle under CentOS have, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.