####touch /mnt/file{1..9}
[root@server94 ~]# date
Sat Jan 19 20:52:37 EST 2019
[root@server94 ~]# at 20:54 #设定任务的执行时间
at> touch file #任务的动作
at> <EOT> #ctrl+d 发起任务
job 1 at Sat Jan 19 20:54:00 2019
[root@server94 ~]# at -l #查看任务列表
1 Sat Jan 19 20:54:00 2019 a root
多个任务可以同时等待被执行
[root@server94 ~]# at 21:00
at> touch 1
at> <EOT>
job 2 at Sat Jan 19 21:00:00 2019
[root@server94 ~]# at 21:01
at> touch 2
at> <EOT>
job 3 at Sat Jan 19 21:01:00 2019
[root@server94 ~]# at -l
2 Sat Jan 19 21:00:00 2019 a root
3 Sat Jan 19 21:01:00 2019 a root
注意:当任务有输出的时候,输出会以邮件的形式发送给任务的发起者
[root@server94 ~]# >/var/spool/mail/root #清空邮件
[root@server94 ~]# mail -u root #查看root用户的邮件
at任务的黑白名单
1.黑名单:
/etc/at.deny #系统中默认存在,在此文件中出现的用户不能执行at命令
[root@server94 ~]# ll /etc/at.deny
-rw-r--r--. 1 root root 1 Jan 29 2014 /etc/at.deny
[root@server94 ~]# vim /etc/at.deny
[root@server94 ~]# cat /etc/at.deny
student
[student@server94 ~]$ at 10:11
You do not have permission to use at.
/etc/cron.deny #系统中默认存在,在此文件中出现的用户不能执行crontab
[root@server94 cron.d]# ll -d /etc/cron.deny
-rw-------. 1 root root 0 Jan 27 2014 /etc/cron.deny
[root@server94 cron.d]# vim /etc/cron.deny
[root@server94 cron.d]# cat /etc/cron.deny
student
[student@server94 ~]$ crontab -e
You (student) are not allowed to use this program (crontab)
See crontab(1) for more information
白名单:
/etc/cron.allow #系统中默认不存在,当文件创建出来的时候,普通用户不能执行,只有在名单中的用户可以使用
[root@server94 cron.d]# ll -d /etc/cron.allow
ls: cannot access /etc/cron.allow: No such file or directory
[root@server94 cron.d]# vim /etc/cron.allow
[root@server94 cron.d]# cat /etc/cron.allow
student
[student@server94 ~]$ crontab -e
crontab: installing new crontab