1.1 Special Permissions U+s/o+t
[[email protected] ~]# ls-ld/bin/ls/usr/bin/passwd/tmp//usr/bin/locate-rwxr-xr-x. 1 root root 117048 Mar 2017/bin/lsdrwxrwxrwt. 3 root root 4096 Jul 16:27/tmp/-rwx--s--x. 1 root slocate 38464 Mar 2015/usr/bin/locate-rwsr-xr-x. 1 root root 30768 Nov 2015/usr/bin/passwd #SUID [[email protected] ~]# ll/bin/ls/bin/touch-rwxr-xr-x. 1 root root 117048 Mar 2017/bin/ls-rwxr-xr-x. 1 root root 52560 Mar 2017/bin/touch[[email protected] ~]# chmod u+s/bin/ls/bin/touch [[email protected] ~]# Ll/bin/ls/bin/touch-rwsr-xr-x. 1 root root 117048 Mar 2017/bin/ls-rwsr-xr-x. 1 root root 52560 Mar 2017/bin/touch[[email protected] ~]# chmod u+s/bin/ls [[email protected] ~]# Ll/bi N/ls-rwsr-xr-x. 1 root root 117048 Mar 2017/bin/ls[[email protected] ~]# stat/bin/ls File: '/bin/ls ' size:117048 Blocks : 232 IO block:4096 regular filedevice:803h/2051d inode:263579 links:1Access: (4755/-rwsr-xr-x) Uid: (0/root) Gid: (0/root) access:2018-08-06 09:13:37.131651698 +0800
modify:2017-03-23 02:52:45.000000000 +0800
change:2018-07-25 16:37:29.016952182 +0800
2nd. Scheduled Tasks (multi-volume)
2.1 定时任务cron
[[email protected] W] #ll-D/etc/cron.*
Drwxr-xr-x. 2 root root 4096 3 05:15/ETC/CRON.D
Drwxr-xr-x. 2 root root 4096 Jul 18:26/etc/cron.daily
-RW-------. 1 root root 0 2016/etc/cron.deny
Drwxr-xr-x. 2 root root 4096 Jul 18:23/etc/cron.hourly
Drwxr-xr-x. 2 root root 4096 Jul 18:24/etc/cron.monthly
Drwxr-xr-x. 2 root root 4096 Sep 2011/etc/cron.weekly
[Email protected] w]#
2.2 Timing Task Cron command crontab
[[email protected] ~]# #crontab-L = = = Cat/var/spool/cron/root crontab-l query is equivalent to cat
[Email protected] ~]# #crontab-E = = = Vi/var/spool/cron/root crontab-e equivalent to Vim
[Email protected] w]### #crontab –r = delet/var/spool/cron/root crontab–r equivalent to delete
-V Lists the status of the user cron job
[[email protected] ~]# #crontab语法检查功能 (scheduled task format)
2.3 Check if scheduled tasks are running? Crond
[[email protected] W] #ps-ef |grep Crond
Root 1597 1 0 Aug07? 00:00:00 Crond
Root 4065 3948 0 16:59 pts/3 00:00:00 grep--color cron
2.4 Boot is self-booting chkconfig |grep Crond
[[email protected] W] #chkconfig |grep Crond
Crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
2.5 Scheduled Task configuration file format:
Format: Minute (minute) (hour) (day) month (mouth) week (week)
What time does 2.5.1 do?
Typically used to periodically back up file data
Every day 8:30 A.M., come to school (go to school) every night 12 o'clock on time, go home and drive (go to bed)
2.6 per minute display of its own name appended to the/tmp/name.log
2.6.1 command
[[email protected] W] #echo Wangweigang >>/tmp/name.log
[[email protected] W] #cat/tmp/name.log
Oldboy
Wang Wei Port
Wangweigang
2.6.2 #书写定时任务
Crontab-e
2.6.3 #检查
# #1. Checking the contents of a file
[[email protected] W] #crontab-l
#printf oldboyedu student at 2018.8.08
-
-
-
-
- echo Wangweigang >>/tm P/name.log
# #2. Check the log
[[email protected] W] #cat/tmp/name.log
Oldboy
Port
Wangweigang
Wangweigang
[[email protected] w]#
2.7 Synchronize the system time every 2 minutes
2.7.1 command
[[email protected] W] #ntpdate Ntp1.aliyun.com
8 17:40:28 ntpdate[4141]: Adjust time server 120.25.115.20 offset 0.248269 sec
[[email Protected] W] #which crond
/usr/sbin/crond
[[email protected] w]#
2.7.2 Write timed Tasks
Crontab-e
/2 /usr/sbin/crondntpdate ntp1.aliyun.com
2.7.3 Check
[[email protected] W] #crontab-l
#printf oldboyedu student at 2018.8.08
# Echo Wangweigang >>/tmp/name.log
/2 /usr/sbin/crondntpdate ntp1.aliyun.com
[Email protected] w]#
2.8 Cases
Run cmd command every 2 hours from 7 o'clock in the morning to 11 o'clock in the morning every day
XX 07-11/2 TF
XX 07,09,11 * TF
2.9 Boot from Boot
- 23,00-07/1 /application/nginx/sbin/nginx-s Reload
XX 23,00-07/1 /application/nginx/sbin/nginx-s Reload
2.10 Self-created file placement scripts
[Email protected] ~]# mkdir-p/server/scripts
[email protected] w]# cat show.sh
Date +%f_%t
You have new mail in/var/spool/mail/root
[Email protected] w]# sh/server/scripts/show.sh
2018-08-08_17:55:26
[Email protected] w]#
Introduction to timed task cron in Linux