相亲网站开发不锈钢网
单一执行的例行性工作:只执行一次就结束
1.1at命令的工作过程
  /etc/at.allow,写在该文件的人可以使用at命令
  /etc/at.deny,黑名单
  两个文件如果都不存在,只有root能使用
 
[root@localhost ~]# systemctl status atd
[root@localhost ~]# ll /var/spool/at
[root@localhost ~]# ll /var/log/cron
 
1.2 at命令详解
#定义三分钟之后显示hello
[root@server ~]# at now + 3 minutes
 
2、循环执行的例行性工作
循环执行的例行性工作:每隔一定的周期就需要执行一次
2.1 crontab
/etc/cron.allow,写在该文件的人可以使用crontab命令
 /etc/cron.deny,黑名单
 两个文件如果都不存在,只有root能使用
[root@localhost ~]# systemctl status crond
[root@localhost ~]# ll /var/log/cron
[root@localhost ~]# ll /var/spool/cron/
 
2.2 crontab命令
[root@localhost zhuo]# crontab --help
crontab: invalid option --'-'
crontab: usage error: unrecognized option
Usage:crontab [options] filecrontab [options]crontab -n [hostname]Options:-u <user>  define user-e         edit user's crontab-l         list user's crontab-r         delete user's crontab-i         prompt before deleting-n <host>  set host in cluster to run users' crontabs-c         get host in cluster to run users' crontabs-T <file>  test a crontab file syntax-s         selinux context-V         print version and exit-x <mask>  enable debuggingDefault operation is replace, per 1003.2
 
2.3 系统的计划任务
[root@localhost ~]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# 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
 
当需要同一时间执行多个脚本时,可以将这多个脚本放在一个目录下,然后使用run-parts来执
 行。
 run-parts:该命令可将后面接的“目录”内的所有文件找出来执行。 
  
