Linux操作系统的计划任务
Linux操作系统的计划任务
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
一.任务计划概述
Linux任务计划、周期性任务执行
未来的某时间点执行一次任务:
at:
指定时间点,执行一次性任务
batch:
系统自行选择空闲时间去执行此处指定的任务
周期性运行某任务:
cron
二.at任务
1>.查看at包
[root@node101.yinzhengjie.org.cn ~]# rpm -ql at
/etc/at.deny
/etc/pam.d/atd
/etc/sysconfig/atd
/usr/bin/at
/usr/bin/atq
/usr/bin/atrm
/usr/bin/batch
/usr/lib/systemd/system/atd.service
/usr/sbin/atd
/usr/sbin/atrun
/usr/share/doc/at-3.1.
/usr/share/doc/at-3.1./ChangeLog
/usr/share/doc/at-3.1./Copyright
/usr/share/doc/at-3.1./Problems
/usr/share/doc/at-3.1./README
/usr/share/doc/at-3.1./timespec
/usr/share/man/man1/at..gz
/usr/share/man/man1/atq..gz
/usr/share/man/man1/atrm..gz
/usr/share/man/man1/batch..gz
/usr/share/man/man5/at.allow..gz
/usr/share/man/man5/at.deny..gz
/usr/share/man/man8/atd..gz
/usr/share/man/man8/atrun..gz
/var/spool/at
/var/spool/at/.SEQ
/var/spool/at/spool
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# rpm -ql at
[root@node101.yinzhengjie.org.cn ~]# rpm -qi at
Name : at
Version : 3.1.
Release : .el7
Architecture: x86_64
Install Date: Tue Jul :: AM CST
Group : System Environment/Daemons
Size :
License : GPLv3+ and GPLv2+ and ISC and MIT and Public Domain
Signature : RSA/SHA256, Mon Nov :: PM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : at-3.1.-.el7.src.rpm
Build Date : Wed Oct :: AM CST
Build Host : x86-.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://ftp.debian.org/debian/pool/main/a/at
Summary : Job spooling tools
Description :
At and batch read commands from standard input or from a specified
file. At allows you to specify that a command will be run at a
particular time. Batch will execute commands when the system load
levels drop to a particular level. Both commands use user's shell. You should install the at package if you need a utility for
time-oriented job control. Note: If it is a recurring job that will
need to be repeated at the same time every day/week, etc. you should
use crontab instead.
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# rpm -qi at
2>.at任务
at命令:at [option] TIME 常用选项[option]:
-V 显示版本信息
-t time 时间格式 [[CC]YY]MMDDhhmm[.ss]
-l 列出指定队列中等待运行的作业;相当于atq
-d 删除指定的作业;相当于atrm
-c 查看具体作业任务
-f /path/file 指定的文件中读取任务
-m 当任务被完成之后,将给用户发送邮件,即使没有标准输出 TIME:定义出什么时候进行at这项任务的时间
HH:MM [YYYY-mm-dd]
noon, midnight, teatime(4pm)
tomorrow
now+#{minutes,hours,days, OR weeks}
遗憾的是at任务本身只能精确到分钟,若想要精确到秒执行,可以使用sleep命令,如让at任务2秒后执行"sleep 2",如果秒也不能满足你的需求,其实还可以使用"usleep"命令来精确到微秒,比如让at任务10微妙后执行"usleep 10"。
执行方式:
)交互式
)输入重定向
)at –f 文件 温馨提示:
作业执行命令的结果中的标准输出和错误以邮件通知给相关用户
依赖于atd服务,需要启动才能实现at任务
at队列存放在/var/spool/at目录中
/etc/at.{allow,deny}控制用户是否能执行at任务
白名单:/etc/at.allow 默认不存在,只有该文件中的用户才能执行at命令,有先级更高,即若黑白名单都存在则以白名单为准。
黑名单:/etc/at.deny 默认存在,拒绝该文件中用户执行at命令,而没有在at.deny 文件中的使用者则可执行
如果两个文件都不存在,只有 root 可以执行 at 命令
[root@node101.yinzhengjie.org.cn ~]# systemctl is-enabled atd #检查atd服务是否开机自启动
enabled
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# systemctl is-enabled atd #检查atd服务是否开机自启动
3>.at时间格式
HH:MM :
在今日的 HH:MM 进行,若该时刻已过,则明天此时执行任务
HH:MM YYYY-MM-DD : --
规定在某年某月的某一天的特殊时刻进行该项任务
HH:MM[am|pm] [Month] [Date]
04pm March
: tomorrow
HH:MM[am|pm] + number [minutes|hours|days|weeks]
在某个时间点再加几个时间后才进行该项任务
now + min
02pm + days
4>.实战案例
[root@node101.yinzhengjie.org.cn ~]# at -l
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# date
Mon Nov :: CST
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# at : #定义一个在22:45执行的一次性任务(操作是关机)
at> poweroff
at> <EOT> #注意,当指令写完后按"ctrl +d"即可结束at任务编辑
job at Mon Nov ::
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# at -l #查看任务列表
Mon Nov :: a root
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /var/spool/at/ #一次性任务会自动保存到该目录下
total
-rwx------ root root Nov : a0000101904fb5
drwx------ root root Oct spool
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# at 22:45 #定义一个在22:45执行的一次性任务(操作是关机)
[root@node101.yinzhengjie.org.cn ~]# at -l
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# date
Tue Nov :: CST
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# at :
at> echo https://www.cnblogs.com/yinzhengjie/
at> rm -f /root/a.txt
at> <EOT>
job at Tue Nov ::
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# at -l
Tue Nov :: a root
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# at -c #查看具体作业任务
#!/bin/sh
# atrun uid= gid=
# mail root
umask
XDG_SESSION_ID=; export XDG_SESSION_ID
HOSTNAME=node101.yinzhengjie.org.cn; export HOSTNAME
SHELL=/bin/bash; export SHELL
HISTSIZE=; export HISTSIZE
SSH_CLIENT=172.30.1.254\ \ ; export SSH_CLIENT
QTDIR=/usr/lib64/qt-3.3; export QTDIR
QTINC=/usr/lib64/qt-3.3/include; export QTINC
SSH_TTY=/dev/pts/; export SSH_TTY
QT_GRAPHICSSYSTEM_CHECKED=; export QT_GRAPHICSSYSTEM_CHECKED
USER=root; export USER
LS_COLORS=rs=:di=\;:ln=\;:mh=:pi=\;:so=\;:do=\;:bd=\;\;:cd=\;\;:or=\;\;:mi=\;\;\;:su=
\;:sg=\;:ca=\;:tw=\;:ow=\;:st=\;:ex=\;:\*.tar=\;:\*.tgz=\;:\*.arc=\;:\*.arj=\;:\*.taz=\;:\*.lha=\;:\*.lz4=\;:\*.lzh=\;:\*.lzma=\;:\*.tlz=\;:\*.txz=\;:\*.tzo=\;:\*.t7z=\;:\*.zip=\;:\*.z=\;:\*.Z=\;:\*.dz=\;:\*.gz=\;:\*.lrz=\;:\*.lz=\;:\*.lzo=\;:\*.xz=\;:\*.bz2=\;:\*.bz=\;:\*.tbz=\;:\*.tbz2=\;:\*.tz=\;:\*.deb=\;:\*.rpm=\;:\*.jar=\;:\*.war=\;:\*.ear=\;:\*.sar=\;:\*.rar=\;:\*.alz=\;:\*.ace=\;:\*.zoo=\;:\*.cpio=\;:\*.7z=\;:\*.rz=\;:\*.cab=\;:\*.jpg=\;:\*.jpeg=\;:\*.gif=\;:\*.bmp=\;:\*.pbm=\;:\*.pgm=\;:\*.ppm=\;:\*.tga=\;:\*.xbm=\;:\*.xpm=\;:\*.tif=\;:\*.tiff=\;:\*.png=\;:\*.svg=\;:\*.svgz=\;:\*.mng=\;:\*.pcx=\;:\*.mov=\;:\*.mpg=\;:\*.mpeg=\;:\*.m2v=\;:\*.mkv=\;:\*.webm=\;:\*.ogm=\;:\*.mp4=\;:\*.m4v=\;:\*.mp4v=\;:\*.vob=\;:\*.qt=\;:\*.nuv=\;:\*.wmv=\;:\*.asf=\;:\*.rm=\;:\*.rmvb=\;:\*.flc=\;:\*.avi=\;:\*.fli=\;:\*.flv=\;:\*.gl=\;:\*.dl=\;:\*.xcf=\;:\*.xwd=\;:\*.yuv=\;:\*.cgm=\;:\*.emf=\;:\*.axv=\;:\*.anx=\;:\*.ogv=\;:\*.ogx=\;:\*.aac=\;:\*.au=\;:\*.flac=\;:\*.mid=\;:\*.midi=\;:\*.mka=\;:\*.mp3=\;:\*.mpc=\;:\*.ogg=\;:\*.ra=\;:\*.wav=\;:\*.axa=\;:\*.oga=\;:\*.spx=\;:\*.xspf=\;:; export LS_COLORSMAIL=/var/spool/mail/root; export MAIL
PATH=/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/home/softwares/jdk1..0_201/bin:/root/bin:/home/softwares
/mysql/bin/; export PATHPWD=/root; export PWD
LANG=en_US.UTF-; export LANG
HISTCONTROL=ignoredups; export HISTCONTROL
SHLVL=; export SHLVL
HOME=/root; export HOME
LOGNAME=root; export LOGNAME
QTLIB=/usr/lib64/qt-3.3/lib; export QTLIB
SSH_CONNECTION=172.30.1.254\ \ 172.30.1.101\ ; export SSH_CONNECTION
LESSOPEN=\|\|/usr/bin/lesspipe.sh\ %s; export LESSOPEN
XDG_RUNTIME_DIR=/run/user/; export XDG_RUNTIME_DIR
cd /root || {
echo 'Execution directory inaccessible' >&
exit
}
${SHELL:-/bin/sh} << 'marcinDELIMITER1feb7a08'
echo https://www.cnblogs.com/yinzhengjie/
rm -f /root/a.txt marcinDELIMITER1feb7a08
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# at -c 3 #查看具体作业任务
[root@node101.yinzhengjie.org.cn ~]# at -l
Tue Nov :: a root
Tue Nov :: a root
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# at -d #删除计划任务
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# at -l
Tue Nov :: a root
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# at -d 5 #删除计划任务
[root@node101.yinzhengjie.org.cn ~]# at -l
Tue Nov :: a root
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo -e "poweroff\ntouch /root/a.txt" | at : #输入重定向的方式定义at任务
job at Tue Nov ::
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# at -l
Tue Nov :: a root
Tue Nov :: a root
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# at -c
#!/bin/sh
# atrun uid= gid=
# mail root
umask
XDG_SESSION_ID=; export XDG_SESSION_ID
HOSTNAME=node101.yinzhengjie.org.cn; export HOSTNAME
SHELL=/bin/bash; export SHELL
HISTSIZE=; export HISTSIZE
SSH_CLIENT=172.30.1.254\ \ ; export SSH_CLIENT
QTDIR=/usr/lib64/qt-3.3; export QTDIR
QTINC=/usr/lib64/qt-3.3/include; export QTINC
SSH_TTY=/dev/pts/; export SSH_TTY
QT_GRAPHICSSYSTEM_CHECKED=; export QT_GRAPHICSSYSTEM_CHECKED
USER=root; export USER
LS_COLORS=rs=:di=\;:ln=\;:mh=:pi=\;:so=\;:do=\;:bd=\;\;:cd=\;\;:or=\;\;:mi=\;\;\;:su=
\;:sg=\;:ca=\;:tw=\;:ow=\;:st=\;:ex=\;:\*.tar=\;:\*.tgz=\;:\*.arc=\;:\*.arj=\;:\*.taz=\;:\*.lha=\;:\*.lz4=\;:\*.lzh=\;:\*.lzma=\;:\*.tlz=\;:\*.txz=\;:\*.tzo=\;:\*.t7z=\;:\*.zip=\;:\*.z=\;:\*.Z=\;:\*.dz=\;:\*.gz=\;:\*.lrz=\;:\*.lz=\;:\*.lzo=\;:\*.xz=\;:\*.bz2=\;:\*.bz=\;:\*.tbz=\;:\*.tbz2=\;:\*.tz=\;:\*.deb=\;:\*.rpm=\;:\*.jar=\;:\*.war=\;:\*.ear=\;:\*.sar=\;:\*.rar=\;:\*.alz=\;:\*.ace=\;:\*.zoo=\;:\*.cpio=\;:\*.7z=\;:\*.rz=\;:\*.cab=\;:\*.jpg=\;:\*.jpeg=\;:\*.gif=\;:\*.bmp=\;:\*.pbm=\;:\*.pgm=\;:\*.ppm=\;:\*.tga=\;:\*.xbm=\;:\*.xpm=\;:\*.tif=\;:\*.tiff=\;:\*.png=\;:\*.svg=\;:\*.svgz=\;:\*.mng=\;:\*.pcx=\;:\*.mov=\;:\*.mpg=\;:\*.mpeg=\;:\*.m2v=\;:\*.mkv=\;:\*.webm=\;:\*.ogm=\;:\*.mp4=\;:\*.m4v=\;:\*.mp4v=\;:\*.vob=\;:\*.qt=\;:\*.nuv=\;:\*.wmv=\;:\*.asf=\;:\*.rm=\;:\*.rmvb=\;:\*.flc=\;:\*.avi=\;:\*.fli=\;:\*.flv=\;:\*.gl=\;:\*.dl=\;:\*.xcf=\;:\*.xwd=\;:\*.yuv=\;:\*.cgm=\;:\*.emf=\;:\*.axv=\;:\*.anx=\;:\*.ogv=\;:\*.ogx=\;:\*.aac=\;:\*.au=\;:\*.flac=\;:\*.mid=\;:\*.midi=\;:\*.mka=\;:\*.mp3=\;:\*.mpc=\;:\*.ogg=\;:\*.ra=\;:\*.wav=\;:\*.axa=\;:\*.oga=\;:\*.spx=\;:\*.xspf=\;:; export LS_COLORSMAIL=/var/spool/mail/root; export MAIL
PATH=/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/home/softwares/jdk1..0_201/bin:/root/bin:/home/softwares
/mysql/bin/; export PATHPWD=/root; export PWD
LANG=en_US.UTF-; export LANG
HISTCONTROL=ignoredups; export HISTCONTROL
SHLVL=; export SHLVL
HOME=/root; export HOME
LOGNAME=root; export LOGNAME
QTLIB=/usr/lib64/qt-3.3/lib; export QTLIB
SSH_CONNECTION=172.30.1.254\ \ 172.30.1.101\ ; export SSH_CONNECTION
LESSOPEN=\|\|/usr/bin/lesspipe.sh\ %s; export LESSOPEN
XDG_RUNTIME_DIR=/run/user/; export XDG_RUNTIME_DIR
cd /root || {
echo 'Execution directory inaccessible' >&
exit
}
${SHELL:-/bin/sh} << 'marcinDELIMITER174f2c3d'
poweroff
touch /root/a.txt marcinDELIMITER174f2c3d
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo -e "poweroff\ntouch /root/a.txt" | at 12:10 #输入重定向的方式定义at任务
[root@node101.yinzhengjie.org.cn ~]# date #观察当前时间
Tue Nov :: CST
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# at -l
Tue Nov :: a root
Tue Nov :: a root
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# at now+10minutes #让任务10分钟之后执行
at> echo min
at> <EOT>
job at Tue Nov :: #我们发现的确是任务添加到10分钟之后了。
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# at -l
Tue Nov :: a root
Tue Nov :: a root
Tue Nov :: a root
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# at -c
#!/bin/sh
# atrun uid= gid=
# mail root
umask
XDG_SESSION_ID=; export XDG_SESSION_ID
HOSTNAME=node101.yinzhengjie.org.cn; export HOSTNAME
SHELL=/bin/bash; export SHELL
HISTSIZE=; export HISTSIZE
SSH_CLIENT=172.30.1.254\ \ ; export SSH_CLIENT
QTDIR=/usr/lib64/qt-3.3; export QTDIR
QTINC=/usr/lib64/qt-3.3/include; export QTINC
SSH_TTY=/dev/pts/; export SSH_TTY
QT_GRAPHICSSYSTEM_CHECKED=; export QT_GRAPHICSSYSTEM_CHECKED
USER=root; export USER
LS_COLORS=rs=:di=\;:ln=\;:mh=:pi=\;:so=\;:do=\;:bd=\;\;:cd=\;\;:or=\;\;:mi=\;\;\;:su=
\;:sg=\;:ca=\;:tw=\;:ow=\;:st=\;:ex=\;:\*.tar=\;:\*.tgz=\;:\*.arc=\;:\*.arj=\;:\*.taz=\;:\*.lha=\;:\*.lz4=\;:\*.lzh=\;:\*.lzma=\;:\*.tlz=\;:\*.txz=\;:\*.tzo=\;:\*.t7z=\;:\*.zip=\;:\*.z=\;:\*.Z=\;:\*.dz=\;:\*.gz=\;:\*.lrz=\;:\*.lz=\;:\*.lzo=\;:\*.xz=\;:\*.bz2=\;:\*.bz=\;:\*.tbz=\;:\*.tbz2=\;:\*.tz=\;:\*.deb=\;:\*.rpm=\;:\*.jar=\;:\*.war=\;:\*.ear=\;:\*.sar=\;:\*.rar=\;:\*.alz=\;:\*.ace=\;:\*.zoo=\;:\*.cpio=\;:\*.7z=\;:\*.rz=\;:\*.cab=\;:\*.jpg=\;:\*.jpeg=\;:\*.gif=\;:\*.bmp=\;:\*.pbm=\;:\*.pgm=\;:\*.ppm=\;:\*.tga=\;:\*.xbm=\;:\*.xpm=\;:\*.tif=\;:\*.tiff=\;:\*.png=\;:\*.svg=\;:\*.svgz=\;:\*.mng=\;:\*.pcx=\;:\*.mov=\;:\*.mpg=\;:\*.mpeg=\;:\*.m2v=\;:\*.mkv=\;:\*.webm=\;:\*.ogm=\;:\*.mp4=\;:\*.m4v=\;:\*.mp4v=\;:\*.vob=\;:\*.qt=\;:\*.nuv=\;:\*.wmv=\;:\*.asf=\;:\*.rm=\;:\*.rmvb=\;:\*.flc=\;:\*.avi=\;:\*.fli=\;:\*.flv=\;:\*.gl=\;:\*.dl=\;:\*.xcf=\;:\*.xwd=\;:\*.yuv=\;:\*.cgm=\;:\*.emf=\;:\*.axv=\;:\*.anx=\;:\*.ogv=\;:\*.ogx=\;:\*.aac=\;:\*.au=\;:\*.flac=\;:\*.mid=\;:\*.midi=\;:\*.mka=\;:\*.mp3=\;:\*.mpc=\;:\*.ogg=\;:\*.ra=\;:\*.wav=\;:\*.axa=\;:\*.oga=\;:\*.spx=\;:\*.xspf=\;:; export LS_COLORSMAIL=/var/spool/mail/root; export MAIL
PATH=/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/home/softwares/jdk1..0_201/bin:/root/bin:/home/softwares
/mysql/bin/; export PATHPWD=/root; export PWD
LANG=en_US.UTF-; export LANG
HISTCONTROL=ignoredups; export HISTCONTROL
SHLVL=; export SHLVL
HOME=/root; export HOME
LOGNAME=root; export LOGNAME
QTLIB=/usr/lib64/qt-3.3/lib; export QTLIB
SSH_CONNECTION=172.30.1.254\ \ 172.30.1.101\ ; export SSH_CONNECTION
LESSOPEN=\|\|/usr/bin/lesspipe.sh\ %s; export LESSOPEN
XDG_RUNTIME_DIR=/run/user/; export XDG_RUNTIME_DIR
cd /root || {
echo 'Execution directory inaccessible' >&
exit
}
${SHELL:-/bin/sh} << 'marcinDELIMITER58f2aecc'
echo min marcinDELIMITER58f2aecc
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# at now+10minutes #让任务10分钟之后执行
[root@node101.yinzhengjie.org.cn ~]# at : <<EOF #也可以使用类似于脚本的方式定义at任务
> touch /root/b.txt
> touch /root/c.txt
> echo "https://www.cnblogs.com/yinzhengjie/"
> EOF
job at Tue Nov ::
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# at -l
Tue Nov :: a root
Tue Nov :: a root
Tue Nov :: a root
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# at 18:10 <<EOF
[root@node101.yinzhengjie.org.cn ~]# su - yinzhengjie #我们使用"yinzhengjie"用户定义一个at任务
Last login: Mon Nov :: CST on pts/
[yinzhengjie@node101.yinzhengjie.org.cn ~]$
[yinzhengjie@node101.yinzhengjie.org.cn ~]$ at :
at> poweroff
at> cat /etc/shadow
at> <EOT>
job at Tue Nov ::
[yinzhengjie@node101.yinzhengjie.org.cn ~]$
[yinzhengjie@node101.yinzhengjie.org.cn ~]$ at -l #查看咱们定义好的任务
Tue Nov :: a yinzhengjie
[yinzhengjie@node101.yinzhengjie.org.cn ~]$
[yinzhengjie@node101.yinzhengjie.org.cn ~]$ exit
logout
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# vim /etc/at.deny #编辑黑名单,让指定用户无权限和查看定义at任务
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat /etc/at.deny
yinzhengjie
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# su - yinzhengjie
Last login: Tue Nov :: CST on pts/
[yinzhengjie@node101.yinzhengjie.org.cn ~]$
[yinzhengjie@node101.yinzhengjie.org.cn ~]$ at -l
You do not have permission to use at.
[yinzhengjie@node101.yinzhengjie.org.cn ~]$
[yinzhengjie@node101.yinzhengjie.org.cn ~]$ at :
You do not have permission to use at.
[yinzhengjie@node101.yinzhengjie.org.cn ~]$
[yinzhengjie@node101.yinzhengjie.org.cn ~]$ exit
logout
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# at -l #虽说"yinzhengjie"已经无权限定义at任务了,但该用户之前定义的任务依旧会执行。
Tue Nov :: a root
Tue Nov :: a root
Tue Nov :: a root
Tue Nov :: a yinzhengjie
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# vim /etc/at.deny #编辑黑名单,让指定用户无权限和查看定义at任务
三.周期性任务计划cron(注意,进入单用户模式下计划任务是不会执行的)
1>.相关的程序包
[root@node101.yinzhengjie.org.cn ~]# rpm -ql cronie #主程序包,提供crond守护进程及相关辅助工具
/etc/cron.d
/etc/cron.d/0hourly
/etc/cron.deny
/etc/pam.d/crond
/etc/sysconfig/crond
/usr/bin/crontab
/usr/lib/systemd/system/crond.service
/usr/sbin/crond
/usr/share/doc/cronie-1.4.
/usr/share/doc/cronie-1.4./AUTHORS
/usr/share/doc/cronie-1.4./COPYING
/usr/share/doc/cronie-1.4./ChangeLog
/usr/share/doc/cronie-1.4./INSTALL
/usr/share/doc/cronie-1.4./README
/usr/share/man/man1/crontab..gz
/usr/share/man/man5/crontab..gz
/usr/share/man/man8/cron..gz
/usr/share/man/man8/crond..gz
/var/spool/cron
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# rpm -ql cronie #主程序包,提供crond守护进程及相关辅助工具
[root@node101.yinzhengjie.org.cn ~]# rpm -ql cronie-anacron #cronie的补充程序,用于监控cronie任务执行状况,如cronie中的任务在过去该运行的时间点未能正常运行,则anacron会随后启动一次此任务
/etc/anacrontab
/etc/cron.hourly/0anacron
/usr/sbin/anacron
/usr/share/man/man5/anacrontab..gz
/usr/share/man/man8/anacron..gz
/var/spool/anacron
/var/spool/anacron/cron.daily
/var/spool/anacron/cron.monthly
/var/spool/anacron/cron.weekly
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# rpm -ql cronie-anacron #cronie的补充程序,用于监控cronie任务执行状况,如cronie中的任务在过去该运行的时间点未能正常运行,则anacron会随后启动一次此任务
[root@node101.yinzhengjie.org.cn ~]# rpm -ql crontabs #包含CentOS提供系统维护任务
/etc/cron.daily
/etc/cron.hourly
/etc/cron.monthly
/etc/cron.weekly
/etc/crontab
/etc/sysconfig/run-parts
/usr/bin/run-parts
/usr/share/man/man4/crontabs..gz
/usr/share/man/man4/run-parts..gz
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# rpm -ql crontabs #包含CentOS提供系统维护任务
2>.确保crond守护处于运行状态
[root@node101.yinzhengjie.org.cn ~]# systemctl status crond
● crond.service - Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
Active: active (running) since Wed -- :: CST; 5min ago
Main PID: (crond)
CGroup: /system.slice/crond.service
└─ /usr/sbin/crond -n Nov :: node101.yinzhengjie.org.cn systemd[]: Started Command Scheduler.
Nov :: node101.yinzhengjie.org.cn crond[]: (CRON) INFO (RANDOM_DELAY will be scaled with factor % if used.)
Nov :: node101.yinzhengjie.org.cn crond[]: (CRON) INFO (running with inotify support)
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# systemctl status crond #CentOS 7.x推荐使用这种方式
[root@node101.yinzhengjie.org.cn ~]# service crond status
Redirecting to /bin/systemctl status crond.service
● crond.service - Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
Active: active (running) since Wed -- :: CST; 6min ago
Main PID: (crond)
CGroup: /system.slice/crond.service
└─ /usr/sbin/crond -n Nov :: node101.yinzhengjie.org.cn systemd[]: Started Command Scheduler.
Nov :: node101.yinzhengjie.org.cn crond[]: (CRON) INFO (RANDOM_DELAY will be scaled with factor % if used.)
Nov :: node101.yinzhengjie.org.cn crond[]: (CRON) INFO (running with inotify support)
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# service crond status
3>.run-parts工具
[root@node101.yinzhengjie.org.cn ~]# mkdir shell
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo "https://www.cnblogs.com/yinzhengjie/" > shell/blog.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# echo "ansible,jekins,gitlab,gerrit,python,golang" > shell/devops.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# chmod +x -R shell/
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll shell/
total
-rwxr-xr-x root root Nov : blog.txt
-rwxr-xr-x root root Nov : devops.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# run-parts shell/ #可以将一个目录下所有可执行脚本统统跑一遍
shell/blog.txt: shell/blog.txt: line : https://www.cnblogs.com/yinzhengjie/: No such file or directory
shell/devops.txt: shell/devops.txt: line : ansible,jekins,gitlab,gerrit,python,golang: command not found
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# run-parts shell/ #可以将一个目录下所有可执行脚本统统跑一遍,会被记录到"/var/log/cron"日志中
4>.时间表示法
特定值:
给定时间点有效取值范围内的值,如表示星期的取值范围为"0-7"(0或者7都表示周日)。月份的取值范围则为"1-12"等。 *:
给定时间点上有效取值范围内的所有值,比如想要表示1-12个月份,那么就不用这么啰嗦,直接使用"*"号(表示"每...")代替即可。 #,#,#:
连续取值,比如每周1,,5九点开始上课,则表示为"00 09 1,3,5 * *"。 #-#
在指定时间范围上,定义步长,比如像表示周一到周五,则"* * * * 1-5"。 /#:
"#"即为步长,比如每十分钟则"*/10 * * * *"。 时间格式:
@reboot:
表示下次重启才会执行。
@yearly *
@annually *
@monthly * *
@weekly * *
@daily * * *
@hourly * * * *
示例:每3小时echo和wall命令
*/ * * * centos /bin/echo "Hello!"; wall "welcome to my blog:'https://www.cnblogs.com/yinzhengjie/'"
5>.计划周期性执行的任务提交给crond,到指定时间会自动运行
系统cron任务:系统维护作业
/etc/crontab(仅适合root用户编写它) 用户cron任务:
crontab命令,适合所有用户去编辑自己的计划任务它是拥有SUID权限的命令。
crontab命令定义:
每个用户都有专用的cron任务文件:/var/spool/cron/USERNAME
crontab语法格式:
crontab [-u user] [-l | -r | -e] [-i]
-l:
列出所有任务
-e:
编辑任务
-r:
移除所有任务
-i:
同-r一同使用,以交互式模式移除指定任务
-u:
user 仅root可运行,指定用户管理cron任务
控制用户执行计划任务:
/etc/cron.{allow,deny} 温馨提示:
更多帮助信息可参考:"man 5 crontab"
运行结果的标准输出和错误以邮件通知给相关用户
COMMAND > /dev/null
COMMAND &> /dev/null
对于cron任务来讲,"%"有特殊用途;如果在命令中要使用"%",则需要转义,将"%"放置于单引号中,则可不用转义
[root@node101.yinzhengjie.org.cn ~]# cat /etc/crontab #root用户定义系统cron任务,该文件的属主属组都是root用户。更多帮助信息详情参见"man 5 crontab"
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root # For details see man crontabs # Example of job definition:
# .---------------- minute ( - )
# | .------------- hour ( - )
# | | .---------- day of month ( - )
# | | | .------- month ( - ) OR jan,feb,mar,apr ...
# | | | | .---- day of week ( - ) (Sunday= or ) OR sun,mon,tue,wed,thu,fri,sat #这里提示我们0或者7表示星期日,-6表示周日,周一,周二,......,周六。
# | | | | |
# * * * * * user-name command to be executed
* -, root /bin/tar cf /root/shell.tar /root/shell &> /dev/null #每年的3,,,,12月份的周日的2:30分都会以root身份执行一下"/bin/tar cf /root/shell.tar /root/shell &> /dev/null"命令,注意命令必须写绝对路径哟~
*/ * * * * root /root/shell/checkdisk.sh #表示每间隔10分钟就以root身份执行一下"checkdisk.sh"脚本
, * root /root/shell/f1.sh #每个月的1,15号或者每个星期日的4:30分都会以root身份执行一下"/root/shell/f1.sh"脚本
@reboot root /bin/rm -rf /data/* #下次重启才会执行该操作,注意,如果重启时进入单用户模式下计划任务是不会执行的。
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /etc/crontab #仅仅适合root用户,因为它的权限为root用户
-rw-r--r-- 1 root root 647 Nov 20 06:37 /etc/crontab
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat /etc/crontab #root用户定义系统cron任务,该文件的属主属组都是root用户。
[root@node101.yinzhengjie.org.cn ~]# which crontab
/usr/bin/crontab
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /usr/bin/crontab #注意,该命令是拥有SUID权限的哟
-rwsr-xr-x. root root Apr /usr/bin/crontab
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# su -l yinzhengjie
Last login: Tue Nov :: CST on pts/
[yinzhengjie@node101.yinzhengjie.org.cn ~]$
[yinzhengjie@node101.yinzhengjie.org.cn ~]$ crontab -e #编辑任务列表,会自动生成一个中间临时文件,编辑并保存成功后会自动写入专用的cron任务文件,即"/var/spool/cron/yinzhengjie"
no crontab for yinzhengjie - using an empty one
crontab: installing new crontab
[yinzhengjie@node101.yinzhengjie.org.cn ~]$
[yinzhengjie@node101.yinzhengjie.org.cn ~]$ crontab -l #查看已经定义的计划任务列表
* * * * * /bin/wall Wellcome to my blog[https://www.cnblogs.com/yinzhengjie/].
[yinzhengjie@node101.yinzhengjie.org.cn ~]$
[yinzhengjie@node101.yinzhengjie.org.cn ~]$ exit
logout
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# crontab -l -u yinzhengjie #查看指定用户的计划任务列表
* * * * * /bin/wall Wellcome to my blog[https://www.cnblogs.com/yinzhengjie/].
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# crontab -l #查看当前root用的计划任务列表,发现当前任务列表为空。
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /var/spool/cron/ #每个用户都有专用的cron任务文件
total
-rw------- root root Nov : root
-rw------- yinzhengjie yinzhengjie Nov : yinzhengjie
[root@node101.yinzhengjie.org.cn ~]#
[yinzhengjie@node101.yinzhengjie.org.cn ~]$ crontab -e #编辑任务列表,会自动生成一个中间临时文件,编辑并保存成功后会自动写入专用的cron任务文件,即"/var/spool/cron/yinzhengjie"。
6>.日志
[root@node101.yinzhengjie.org.cn ~]# cat /var/log/cron
Jul :: localhost crond[]: (CRON) INFO (RANDOM_DELAY will be scaled with factor % if used.)
Jul :: localhost crond[]: (CRON) INFO (running with inotify support)
Jul :: node101 crond[]: (CRON) INFO (RANDOM_DELAY will be scaled with factor % if used.)
Jul :: node101 crond[]: (CRON) INFO (running with inotify support)
Jul :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Jul :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Jul :: node101 anacron[]: Anacron started on --
Jul :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Jul :: node101 anacron[]: Will run job `cron.daily' in 48 min.
Jul :: node101 anacron[]: Will run job `cron.weekly' in 68 min.
Jul :: node101 anacron[]: Will run job `cron.monthly' in 88 min.
Jul :: node101 anacron[]: Jobs will be executed sequentially
Jul :: node101 crond[]: (CRON) INFO (RANDOM_DELAY will be scaled with factor % if used.)
Jul :: node101 crond[]: (CRON) INFO (running with inotify support)
Jul :: node101 crond[]: (CRON) INFO (RANDOM_DELAY will be scaled with factor % if used.)
Jul :: node101 crond[]: (CRON) INFO (running with inotify support)
Jul :: node101 crond[]: (CRON) INFO (RANDOM_DELAY will be scaled with factor % if used.)
Jul :: node101 crond[]: (CRON) INFO (running with inotify support)
Jul :: node101 crond[]: (CRON) INFO (RANDOM_DELAY will be scaled with factor % if used.)
Jul :: node101 crond[]: (CRON) INFO (running with inotify support)
Jul :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Jul :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Jul :: node101 anacron[]: Anacron started on --
Jul :: node101 anacron[]: Will run job `cron.daily' in 35 min.
Jul :: node101 anacron[]: Will run job `cron.weekly' in 55 min.
Jul :: node101 anacron[]: Will run job `cron.monthly' in 75 min.
Jul :: node101 anacron[]: Jobs will be executed sequentially
Jul :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Jul :: node101 crond[]: (CRON) INFO (Shutting down)
Jul :: node101 crond[]: (CRON) INFO (RANDOM_DELAY will be scaled with factor % if used.)
Jul :: node101 crond[]: (CRON) INFO (running with inotify support)
Jul :: node101 crond[]: (CRON) INFO (@reboot jobs will be run at computer's startup.)
Nov :: node101 crond[]: (CRON) INFO (RANDOM_DELAY will be scaled with factor % if used.)
Nov :: node101 crond[]: (CRON) INFO (running with inotify support)
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 anacron[]: Anacron started on --
Nov :: node101 anacron[]: Will run job `cron.daily' in 25 min.
Nov :: node101 anacron[]: Will run job `cron.weekly' in 45 min.
Nov :: node101 anacron[]: Will run job `cron.monthly' in 65 min.
Nov :: node101 anacron[]: Jobs will be executed sequentially
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 anacron[]: Job `cron.daily' started
Nov :: node101 run-parts(/etc/cron.daily)[]: starting logrotate
Nov :: node101 run-parts(/etc/cron.daily)[]: finished logrotate
Nov :: node101 run-parts(/etc/cron.daily)[]: starting man-db.cron
Nov :: node101 run-parts(/etc/cron.daily)[]: finished man-db.cron
Nov :: node101 anacron[]: Job `cron.daily' terminated
Nov :: node101 anacron[]: Job `cron.weekly' started
Nov :: node101 anacron[]: Job `cron.weekly' terminated
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 anacron[]: Job `cron.monthly' started
Nov :: node101 anacron[]: Job `cron.monthly' terminated
Nov :: node101 anacron[]: Normal exit ( jobs run)
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 anacron[]: Anacron started on --
Nov :: node101 anacron[]: Normal exit ( jobs run)
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 anacron[]: Anacron started on --
Nov :: node101 anacron[]: Normal exit ( jobs run)
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 anacron[]: Anacron started on --
Nov :: node101 anacron[]: Normal exit ( jobs run)
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 anacron[]: Anacron started on --
Nov :: node101 anacron[]: Will run job `cron.daily' in 48 min.
Nov :: node101 anacron[]: Jobs will be executed sequentially
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 anacron[]: Job `cron.daily' started
Nov :: node101 run-parts(/etc/cron.daily)[]: starting logrotate
Nov :: node101 run-parts(/etc/cron.daily)[]: finished logrotate
Nov :: node101 run-parts(/etc/cron.daily)[]: starting man-db.cron
Nov :: node101 run-parts(/etc/cron.daily)[]: finished man-db.cron
Nov :: node101 anacron[]: Job `cron.daily' terminated
Nov :: node101 anacron[]: Normal exit ( job run)
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 crond[]: (CRON) INFO (RANDOM_DELAY will be scaled with factor % if used.)
Nov :: node101 crond[]: (CRON) INFO (running with inotify support)
Nov :: node101 crond[]: (CRON) INFO (Shutting down)
Nov :: node101 crond[]: (CRON) INFO (RANDOM_DELAY will be scaled with factor % if used.)
Nov :: node101 crond[]: (CRON) INFO (running with inotify support)
Nov :: node101 crond[]: (CRON) INFO (RANDOM_DELAY will be scaled with factor % if used.)
Nov :: node101 crond[]: (CRON) INFO (running with inotify support)
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 crond[]: (CRON) INFO (RANDOM_DELAY will be scaled with factor % if used.)
Nov :: node101 crond[]: (CRON) INFO (running with inotify support)
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 crond[]: (CRON) INFO (Shutting down)
Nov :: node101 crond[]: (CRON) INFO (RANDOM_DELAY will be scaled with factor % if used.)
Nov :: node101 crond[]: (CRON) INFO (running with inotify support)
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 crond[]: (CRON) INFO (RANDOM_DELAY will be scaled with factor % if used.)
Nov :: node101 crond[]: (CRON) INFO (running with inotify support)
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 anacron[]: Anacron started on --
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 anacron[]: Will run job `cron.daily' in 16 min.
Nov :: node101 anacron[]: Jobs will be executed sequentially
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 anacron[]: Job `cron.daily' started
Nov :: node101 run-parts(/etc/cron.daily)[]: starting logrotate
Nov :: node101 run-parts(/etc/cron.daily)[]: finished logrotate
Nov :: node101 run-parts(/etc/cron.daily)[]: starting man-db.cron
Nov :: node101 run-parts(/etc/cron.daily)[]: finished man-db.cron
Nov :: node101 anacron[]: Job `cron.daily' terminated
Nov :: node101 anacron[]: Normal exit ( job run)
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 CROND[]: (root) CMD (run-parts /etc/cron.hourly)
Nov :: node101 run-parts(/etc/cron.hourly)[]: starting 0anacron
Nov :: node101 run-parts(/etc/cron.hourly)[]: finished 0anacron
Nov :: node101 crond[]: (CRON) INFO (RANDOM_DELAY will be scaled with factor % if used.)
Nov :: node101 crond[]: (CRON) INFO (running with inotify support)
Nov :: node101 CROND[]: (root) CMD (/usr/lib64/sa/sa1 )
Nov :: node101 run-parts(shell/)[]: starting blog.txt
Nov :: node101 run-parts(shell/)[]: finished blog.txt
Nov :: node101 run-parts(shell/)[]: starting devops.txt
Nov :: node101 run-parts(shell/)[]: finished devops.txt
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat /var/log/cron
7>.系统的计划任务
/etc/crontab
计划任务主配置文件,仅root用户有权限操作。
/etc/cron.d/
存放计划任务的配置文件
/etc/cron.hourly/
定义每小时要执行的任务,如"0anacron"脚本,用来检查anacron今天是否执行
/etc/cron.daily/
定义每天要执行的任务
/etc/cron.weekly/
定义每个星期要执行的任务
/etc/cron.monthly/
定义每个月要执行的任务
[root@node101.yinzhengjie.org.cn ~]# ll /etc/crontab
-rw-r--r-- root root Nov : /etc/crontab
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root # For details see man crontabs # Example of job definition:
# .---------------- minute ( - )
# | .------------- hour ( - )
# | | .---------- day of month ( - )
# | | | .------- month ( - ) OR jan,feb,mar,apr ...
# | | | | .---- day of week ( - ) (Sunday= or ) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
* -, root /bin/tar cf /root/shell.tar /root/shell &> /dev/null
*/ * * * * root /root/shell/checkdisk.sh
, * root /root/shell/f1.sh
@reboot root /bin/rm -rf /data/*
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat /etc/crontab
[root@node101.yinzhengjie.org.cn ~]# ll /etc/cron.d/
total
-rw-r--r--. root root Apr 0hourly
-rw------- root root Aug : sysstat
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat /etc/cron.d/0hourly
# Run the hourly jobs
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
* * * * root run-parts /etc/cron.hourly
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat /etc/cron.d/sysstat
# Run system activity accounting tool every minutes
*/ * * * * root /usr/lib64/sa/sa1
# * * * * root /usr/lib64/sa/sa1 &
# Generate a daily summary of process accounting at :
* * * root /usr/lib64/sa/sa2 -A [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /etc/cron.d/
[root@node101.yinzhengjie.org.cn ~]# ll /etc/cron.hourly/
total
-rwxr-xr-x. root root Apr 0anacron
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat /etc/cron.hourly/0anacron
#!/bin/sh
# Check whether 0anacron was run today already
if test -r /var/spool/anacron/cron.daily; then
day=`cat /var/spool/anacron/cron.daily`
fi
if [ `date +%Y%m%d` = "$day" ]; then
exit ;
fi # Do not run jobs when on battery power
if test -x /usr/bin/on_ac_power; then
/usr/bin/on_ac_power >/dev/null >&
if test $? -eq ; then
exit
fi
fi
/usr/sbin/anacron -s
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /etc/cron.hourly/ #查看系统每小时要执行的计划任务
[root@node101.yinzhengjie.org.cn ~]# ll /etc/cron.daily/
total
-rwx------. root root Oct logrotate
-rwxr-xr-x. root root Oct man-db.cron
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat /etc/cron.daily/logrotate
#!/bin/sh /usr/sbin/logrotate -s /var/lib/logrotate/logrotate.status /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat /etc/cron.daily/man-db.cron
#!/bin/bash if [ -e /etc/sysconfig/man-db ]; then
. /etc/sysconfig/man-db
fi if [ "$CRON" = "no" ]; then
exit
fi renice + -p $$ >/dev/null >&
ionice -c3 -p $$ >/dev/null >& LOCKFILE=/var/lock/man-db.lock # the lockfile is not meant to be perfect, it's just in case the
# two man-db cron scripts get run close to each other to keep
# them from stepping on each other's toes. The worst that will
# happen is that they will temporarily corrupt the database
[[ -f $LOCKFILE ]] && exit trap "{ rm -f $LOCKFILE ; exit 0; }" EXIT
touch $LOCKFILE
# create/update the mandb database
mandb $OPTS exit
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /etc/cron.daily/ #查看每天要执行的计划任务
8>.anacron系统
运行计算机关机时cron不运行的任务,CentOS6以后版本取消anacron服务,由crond服务管理
对笔记本电脑、台式机、工作站、偶尔要关机的服务器及其它不一直开机的系统很重要对很有用
配置文件:/etc/anacrontab,负责执行/etc/ cron.daily /etc/cron.weekly /etc/cron.monthly中系统任务
字段1:如果在这些日子里没有运行这些任务……
字段2:在重新引导后等待这么多分钟后运行它
字段3:任务识别器,在日志文件中标识
字段4:要执行的任务
由/etc/cron.hourly/0anacron执行
当执行任务时,更新/var/spool/anacron/cron.daily 文件的时间戳
9>.管理临时文件
CentOS6使用/etc/cron.daily/tmpwatch定时清除临时文件 CentOS7使用systemd-tmpfiles-setup服务实现 配置文件:
/etc/tmpfiles.d/*.conf
/run/tmpfiles.d/*.conf
/usr/lib/tmpfiles/*.conf
/usr/lib/tmpfiles.d/tmp.conf
d /tmp 1777 root root 10d
d /var/tmp 1777 root root 30d 命令:
systemd-tmpfiles –clean|remove|create configfile
四.at和crontab
一次性作业使用 at 重复性作业使用crontab
Create at time crontab -e
List at -l crontab -l
Details at -c jobnum crontab -l
Remove at -d jobnum crontab -r
Edit N/A crontab -e 没有被重定向的输出会被邮寄给用户 root能够修改其它用户的作业 温馨提示:
运行结果的标准输出和错误以邮件通知给相关用户
COMMAND > /dev/null
COMMAND &> /dev/null
对于cron任务来讲,"%"有特殊用途;如果在命令中要使用"%",则需要转义,将"%"放置于单引号中,则可不用转义
五.小试牛刀
1>.思考
() 如何在秒级别运行任务?
* * * * * for min in ; do echo "hi"; sleep ; done
() 如何实现每7分钟运行一次任务?
sleep命令:
sleep NUMBER[SUFFIX]...
SUFFIX:
s: 秒, 默认
m: 分
h: 小时
d: 天
usleep命令:
比sleep更精确,可以达到微妙。
2>.每周的工作日1:30,将/etc备份至/backup目录中,保存的文件名称格式为“etcbak-yyyy-mm-dd-HH.tar.xz”,其中日期是前一天的时间
[root@node101.yinzhengjie.org.cn ~]# vim shell/backup_etc.sh
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat shell/backup_etc.sh
#!/bin/bash
#
#********************************************************************
#Author: yinzhengjie
#Email: y1053419035@qq.com
#Date: --
#FileName: hello.sh
#URL: http://www.cnblogs.com/yinzhengjie
#Description: This is the first script
#Copyright (C): Original works, no reprint! Otherwise, legal liability will be investigated
#********************************************************************
tar Jcf /backup/etcbak-`date -d yesterday +%F-%H`.tar.xz /etc/ &> /dev/null
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# chmod +x shell/backup_etc.sh
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll shell/
total
-rwxr-xr-x root root Nov : backup_etc.sh
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# crontab -e
crontab: installing new crontab
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# crontab -l
* * - /root/shell/backup_etc.sh
[root@node101.yinzhengjie.org.cn ~]#
参考案例
3>.每两小时取出当前系统/proc/meminfo文件中以S或M开头的信息追至/tmp/meminfo.txt文件中
3>.工作日时间,每10分钟执行一次磁盘空间检查,一旦发现任何分区利用率高于80%,就执行wall警报
[root@node101.yinzhengjie.org.cn ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/centos-root % /
devtmpfs % /dev
tmpfs % /dev/shm
tmpfs % /run
tmpfs % /sys/fs/cgroup
/dev/sda1 % /boot
/dev/mapper/centos-home % /home
tmpfs % /run/user/
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# df | sed -nr '/^\/dev\/sd/s/.* ([0-9]+)%.*/\1/p' [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# df | sed -nr '/^\/dev\/mapper/s/.* ([0-9]+)%.*/\1/p' [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# [ `df | sed -nr '/^\/dev\/mapper/s/.* ([0-9]+)%.*/\1/p' | sort -nr | head -` -gt ] && wall disk will be full
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
参考案例
Linux操作系统的计划任务的更多相关文章
- Linux操作系统计划任务
++++++++++++++++++++++++++++++++++++++++++++++++标题:Linux操作系统的计划任务内容:计划任务分为单次任务和周期性任务,周期任务分为系统级计划任务和用 ...
- Linux操作系统的种种集成开发环境
Linux操作系统的种种集成开发环境 随着Linux的逐渐兴起,已经有为数众多的程序在上面驰骋了,许多开发环境(Development Environment)也应运而生.好的开发环境一定是集成了编辑 ...
- 计算机与linux操作系统的发展
一.计算机 (一)计算机的概念 1.概念:计算机(computer)俗称电脑,是一种用于高速计算的电子计算机器,可以进行数值计算,又可以进行逻辑计算,还具有存储记忆功能.是能够按照程序运行,自动.高速 ...
- Linux任务计划
Linux任务计划: 一次性任务执行(at.batch): at:定时任务,指定一个时间执行一个任务,只能执行一次. at使用方式: 交互式:让用户在at>提示符输入多个要执行的命令: 批处理: ...
- 如何提高Linux操作系统的安全性 转自https://yq.aliyun.com/articles/24251?spm=5176.100239.blogcont24250.7.CfBYE9
摘要: Linux系统不论在功能上.价格上或性能上都有很多优点,但作为开放式操作系统,它不可避免地存在一些安全隐患.关于如何解决这些隐患,为应用提供一个安全的操作平台,本文会告诉你一些最基本.最常用, ...
- 配置Linux任务计划
Linux有三种计划任务: at:指定一个时间执行一个任务 (适用一个或多个任务,执行一次后就不用) cron:根据一个时间表自动执行任务 (使用一个或多个任务,周期性执行) 系统级别的计划任务及其扩 ...
- Linux操作系统的简单认识
1:Linux操作系统的历史 Linux操作系统是由unix操作系统发展而来的,但是Unix是收费的系统,而Linux操作系统的免费的,开源的,所以使用比较广泛,但是它是基于命令行的,不提供图形化用户 ...
- Linux操作系统的LILO详解
LILO是一个在Linux环境编写的Boot Loader程序(所以安装和配置它都要在Linux下).它的主要功能就是引导Linux操作系统的启动.但是它不仅可以引导Linux,它还可以引导其他操作系 ...
- 揭开Linux操作系统的Swap交换区之谜
揭开Linux操作系统的Swap交换区之谜 Swap,即交换区,除了安装Linux的时候,有多少人关心过它呢?其实,Swap的调整对Linux服务器,特别是Web服务器的性能至关重要.通过调整Swap ...
随机推荐
- jQuery 标单验证
jQuery Validate jQuery Validate 插件为表单提供了强大的验证功能,让客户端表单验证变得更简单,同时提供了大量的定制选项,满足应用程序各种需求.该插件捆绑了一套有用的验证方 ...
- PAT 甲级 树专题小结
1.已知两个序链表建树 先序中序建树 PAT 1086 node *buildTree(vector<int>pre,vector<int>in,int pl,int pr,i ...
- robotframework启动ride失败,提示wxpython ImportError: DLL load failed: 找不到指定的模块
背景:按照rf的操作,安装是没有问题,就是在启动ride.py 这个文件,就有问题了,提示 wxpython ImportError: DLL load failed: 找不到指定的模块 在pytho ...
- docker 国内镜像加速
CentOS7 对于使用 systemd 的系统,请在 /etc/docker/daemon.json 中写入如下内容(如果文件不存在请新建该文件): {"registry-mirrors& ...
- 仿简书MarkDown编辑器可同步滚动
模仿简书的MarkDown编辑器,使用Angular8写的示例 1.支持同步滚动 编辑的过程中,右侧预览界面会同步滚动.滚动右侧预览界面,左侧编辑区也会同步滚动哦 2.支持语法高亮 如下: using ...
- lnmp+discuz使用redis缓存(待进一步研究)
一直说Redis.Redis缓存.一直不清楚怎么用.于是花点时间研究了一下,但是还没搞懂.先把大概内容记录一下,待后续继续学习 1.首先部署lnmp环境,这个我的博客有些,请自行搜索 2.给php添加 ...
- 大数据分析常用去重算法分析『Bitmap 篇』
大数据分析常用去重算法分析『Bitmap 篇』 mp.weixin.qq.com 去重分析在企业日常分析中的使用频率非常高,如何在大数据场景下快速地进行去重分析一直是一大难点.在近期的 Apache ...
- php7.4 更新特性
PHP 7.4.0 Released! The PHP development team announces the immediate availability of PHP 7.4.0. This ...
- 利用docker搭建RTMP直播流服务器实现直播
一.rtmp服务器搭建 环境: centos 7.* 1.先安装docker(省略) 2.下载docker容器 docker pull alfg/nginx-rtmp 3.运行容器(记得打开防火墙端口 ...
- Website Scraping with Python 阅读笔记
第一章 工程涉及的基本工具:requests, beautiful soup, scrapy. 法规与技术约定:read the Terms & Conditions and the Priv ...