计划任务at
计划任务at
2013-03-09 saturday
at
1、查询软件是否安装
[root@desktop4 ~]# rpm -q at
at-3.1.10-43.el6.x86_64
[root@desktop4 ~]#
2、服务是否开启
[root@desktop4 ~]# service atd status
atd (pid 2281) is running...
[root@desktop4 ~]# service atd stop
Stopping atd:
[ OK ]
[root@desktop4 ~]# service atd start
Starting atd:
[ OK ]
[root@desktop4 ~]# service atd status
atd (pid 4030) is running...
[root@desktop4 ~]#
3、设置长期有效
[root@desktop4 ~]# chkconfig --list atd
atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
[root@desktop4 ~]#
[root@desktop4 ~]# chkconfig --level 35 atd off
[root@desktop4 ~]#
[root@desktop4 ~]# chkconfig --list atd
atd 0:off 1:off 2:off 3:off 4:on 5:off 6:off
[root@desktop4 ~]#
[root@desktop4 ~]# chkconfig --level 35 atd on
[root@desktop4 ~]#
[root@desktop4 ~]# chkconfig --list atd
atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
[root@desktop4 ~]#
[root@desktop4 ~]#
4、管理at工作
(1)建立at工作
[root@desktop4 ~]# at 15:30
at> init 6
at>
job 2 at 2013-03-09 15:30
[root@desktop4 ~]#
(2)查询at队列
[root@desktop4 ~]# atq
2 2013-03-09 15:30 a root
[root@desktop4 ~]#
[root@desktop4 ~]# at -l
2 2013-03-09 15:30 a root
[root@desktop4 ~]#
(3)查看at工作内容
[root@desktop4 ~]# at -c 2
#!/bin/sh
# atrun uid=0 gid=0
# mail root 0
umask 22
ORBIT_SOCKETDIR=/tmp/orbit-root; export ORBIT_SOCKETDIR
HOSTNAME=desktop4.example.com; export HOSTNAME
IMSETTINGS_INTEGRATE_DESKTOP=yes; export IMSETTINGS_INTEGRATE_DESKTOP
SHELL=/bin/bash; export SHELL
XDG_SESSION_COOKIE=551055dcd66cd454041dddca00000022-1362812677.11524-871624707; export XDG_SESSION_COOKIE
HISTSIZE=1000; export HISTSIZE
GTK_RC_FILES=/etc/gtk/gtkrc:/root/.gtkrc-1.2-gnome2; export GTK_RC_FILES
WINDOWID=18874371; export WINDOWID
QTDIR=/usr/lib64/qt-3.3; export QTDIR
QTINC=/usr/lib64/qt-3.3/include; export QTINC
IMSETTINGS_MODULE=X\ compose\ table; export IMSETTINGS_MODULE
USER=root; export USER
LS_COLORS=rs=0:di=01\;34:ln=01\;36:mh=00:pi=40\;33:so=01\;35:do=01\;35:bd=40\;33\;01:cd=40\;33\;01:or=40\;31\;01:mi=01\;05\;37\;41:su=37\;41:sg=30\;43:ca=30\;41:tw=30\;42:ow=34\;42:st=37\;44:ex=01\;32:\*.tar=01\;31:\*.tgz=01\;31:\*.arj=01\;31:\*.taz=01\;31:\*.lzh=01\;31:\*.lzma=01\;31:\*.tlz=01\;31:\*.txz=01\;31:\*.zip=01\;31:\*.z=01\;31:\*.Z=01\;31:\*.dz=01\;31:\*.gz=01\;31:\*.lz=01\;31:\*.xz=01\;31:\*.bz2=01\;31:\*.tbz=01\;31:\*.tbz2=01\;31:\*.bz=01\;31:\*.tz=01\;31:\*.deb=01\;31:\*.rpm=01\;31:\*.jar=01\;31:\*.rar=01\;31:\*.ace=01\;31:\*.zoo=01\;31:\*.cpio=01\;31:\*.7z=01\;31:\*.rz=01\;31:\*.jpg=01\;35:\*.jpeg=01\;35:\*.gif=01\;35:\*.bmp=01\;35:\*.pbm=01\;35:\*.pgm=01\;35:\*.ppm=01\;35:\*.tga=01\;35:\*.xbm=01\;35:\*.xpm=01\;35:\*.tif=01\;35:\*.tiff=01\;35:\*.png=01\;35:\*.svg=01\;35:\*.svgz=01\;35:\*.mng=01\;35:\*.pcx=01\;35:\*.mov=01\;35:\*.mpg=01\;35:\*.mpeg=01\;35:\*.m2v=01\;35:\*.mkv=01\;35:\*.ogm=01\;35:\*.mp4=01\;35:\*.m4v=01\;35:\*.mp4v=01\;35:\*.vob=01\;35:\*.qt=01\;35:\*.nuv=01\;35:\*.wmv=01\;35:\*.asf=01\;35:\*.rm=01\;35:\*.rmvb=01\;35:\*.flc=01\;35:\*.avi=01\;35:\*.fli=01\;35:\*.flv=01\;35:\*.gl=01\;35:\*.dl=01\;35:\*.xcf=01\;35:\*.xwd=01\;35:\*.yuv=01\;35:\*.cgm=01\;35:\*.emf=01\;35:\*.axv=01\;35:\*.anx=01\;35:\*.ogv=01\;35:\*.ogx=01\;35:\*.aac=01\;36:\*.au=01\;36:\*.flac=01\;36:\*.mid=01\;36:\*.midi=01\;36:\*.mka=01\;36:\*.mp3=01\;36:\*.mpc=01\;36:\*.ogg=01\;36:\*.ra=01\;36:\*.wav=01\;36:\*.axa=01\;36:\*.oga=01\;36:\*.spx=01\;36:\*.xspf=01\;36:; export LS_COLORS
GNOME_KEYRING_SOCKET=/tmp/keyring-IroWjf/socket; export GNOME_KEYRING_SOCKET
SSH_AUTH_SOCK=/tmp/keyring-IroWjf/socket.ssh; export SSH_AUTH_SOCK
SESSION_MANAGER=local/unix:@/tmp/.ICE-unix/3639,unix/unix:/tmp/.ICE-unix/3639; export SESSION_MANAGER
USERNAME=root; export USERNAME
DESKTOP_SESSION=gnome; export DESKTOP_SESSION
MAIL=/var/spool/mail/root; export MAIL
PATH=/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/root/bin; export PATH
QT_IM_MODULE=xim; export QT_IM_MODULE
PWD=/root; export PWD
XMODIFIERS=@im=none; export XMODIFIERS
GDM_KEYBOARD_LAYOUT=us; export GDM_KEYBOARD_LAYOUT
LANG=en_US.UTF-8; export LANG
GNOME_KEYRING_PID=3630; export GNOME_KEYRING_PID
GDM_LANG=en_US.UTF-8; export GDM_LANG
GDMSESSION=gnome; export GDMSESSION
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass; export SSH_ASKPASS
HISTCONTROL=ignoredups; export HISTCONTROL
HOME=/root; export HOME
SHLVL=2; export SHLVL
GNOME_DESKTOP_SESSION_ID=this-is-deprecated; export GNOME_DESKTOP_SESSION_ID
LOGNAME=root; export LOGNAME
QTLIB=/usr/lib64/qt-3.3/lib; export QTLIB
CVS_RSH=ssh; export CVS_RSH
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-DQHKoNPeN6,guid=37107fffffb40e5e3cb136c9000008cb; export DBUS_SESSION_BUS_ADDRESS
LESSOPEN=\|/usr/bin/lesspipe.sh\ %s; export LESSOPEN
WINDOWPATH=7; export WINDOWPATH
G_BROKEN_FILENAMES=1; export G_BROKEN_FILENAMES
XAUTHORITY=/var/run/gdm/auth-for-root-bntku9/database; export XAUTHORITY
COLORTERM=gnome-terminal; export COLORTERM
cd /root || {
echo 'Execution directory inaccessible' >&2
exit 1
}
${SHELL:-/bin/sh} << 'marcinDELIMITER36c5ca6e'
init 6
marcinDELIMITER36c5ca6e
[root@desktop4 ~]#
(4)删除at工作队列
[root@desktop4 ~]# atrm 2
(5)查询结果
[root@desktop4 ~]# atq
[root@desktop4 ~]#
[root@desktop4 ~]# at -l
[root@desktop4 ~]#
5、at服务的访问控制
[root@desktop4 ~]# cat /etc/at.allow
cat: /etc/at.allow: No such file or directory
[root@desktop4 ~]# cat /etc/at.deny
(1)编辑允许使用at的用户
[root@desktop4 ~]# vim /etc/at.allow
chenglong
lilianjie
lixiaolong
(2)编辑拒绝使用at的用户
[root@desktop4 ~]# vim /etc/at.deny
lilianjie
lixiaolong
linxinru
(3)编辑用户
[root@desktop4 ~]# useradd chenglong
[root@desktop4 ~]# passwd chenglong
Changing password for user chenglong.
New password:
BAD PASSWORD: it is based on a dictionary word
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.
[root@desktop4 ~]# useradd lilianjie
[root@desktop4 ~]# passwd lilianjie
Changing password for user lilianjie.
New password:
BAD PASSWORD: it is based on a dictionary word
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.
[root@desktop4 ~]# useradd lixiaolong
[root@desktop4 ~]# passwd lixiaolong
Changing password for user lixiaolong.
New password:
BAD PASSWORD: it is based on a dictionary word
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.
[root@desktop4 ~]# useradd linxinru
[root@desktop4 ~]# passwd linxinru
Changing password for user linxinru.
New password:
BAD PASSWORD: it is based on a dictionary word
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.
[root@desktop4 ~]#
(4)验证
[root@desktop4 ~]# su - chenglong
[chenglong@desktop4 ~]$ pwd
/home/chenglong
[chenglong@desktop4 ~]$ at 16:00
at> vim 001.txt
at>
job 3 at 2013-03-09 16:00
[chenglong@desktop4 ~]$
[chenglong@desktop4 ~]$ exit
logout
[root@desktop4 ~]#
[root@desktop4 ~]# su - lilianjie
[lilianjie@desktop4 ~]$ at 16:00
at> vim 002.txt
at>
job 4 at 2013-03-09 16:00
[lilianjie@desktop4 ~]$
[lilianjie@desktop4 ~]$ exit
logout
[root@desktop4 ~]#
[root@desktop4 ~]# su - lixiaolong
[lixiaolong@desktop4 ~]$ at 16:00
at> vim 003.txt
at>
job 5 at 2013-03-09 16:00
[lixiaolong@desktop4 ~]$ exit
logout
[root@desktop4 ~]#
[root@desktop4 ~]# su - linxinru
[linxinru@desktop4 ~]$
[linxinru@desktop4 ~]$ at 16:00
You do not have permission to use at.
[linxinru@desktop4 ~]$ exit
logout
[root@desktop4 ~]#
(5)查询结果
[root@desktop4 ~]# atq
3 2013-03-09 16:00 a chenglong
4 2013-03-09 16:00 a lilianjie
5 2013-03-09 16:00 a lixiaolong
[root@desktop4 ~]#
(6)清空访问控制列表
[root@desktop4 ~]# vim /etc/at.allow
clear
[root@desktop4 ~]# vim /etc/at.deny
clear
6、备份与还原
(1)首先关闭服务
[root@desktop4 ~]# service atd status
atd (pid 4030) is running...
[root@desktop4 ~]# service atd stop
Stopping atd: [ OK ]
[root@desktop4 ~]# service atd status
atd is stopped
(2)打包文件
[root@desktop4 ~]# tar czf at-backup.tar /etc/at.* /var/spool/at/
tar: Removing leading `/' from member names
(3)删除原文件
[root@desktop4 at]# rm -rf /var/spool/at/*
[root@desktop4 at]#
(4)验证
[root@desktop4 at]# service atd start
Starting atd: [ OK ]
[root@desktop4 ~]# atq
[root@desktop4 ~]#
(5)解包(先停止服务)
[root@desktop7 ~]# service atd stop
Stopping atd: [ OK ]
[root@desktop7 ~]#
[root@desktop4 ~]# cd /
[root@desktop4 /]# tar xvf ~/at-backup.tar
etc/at.allow
etc/at.deny
var/spool/at/a00003015a9500
var/spool/at/a00004015a9500
var/spool/at/a00005015a9500
var/spool/at/spool/
You have new mail in /var/spool/mail/root
[root@desktop4 /]#
[root@desktop7 ~]# service atd start
Starting atd: [ OK ]
[root@desktop7 ~]#
[root@desktop4 /]# atq
3 2013-03-09 16:00 a chenglong
4 2013-03-09 16:00 a lilianjie
5 2013-03-09 16:00 a lixiaolong
[root@desktop4 /]#
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~