#安装at yum install -y at 或 apt-get install at -y #启动守护进程 service atd start 或 systemctl start atd #查看是否开机启动(关于systemctl请看这一篇) chkconfig --list|grep atd 或 systemctl list-unit-files|grep atd #设置开机启动 chkconfig --level 235 atd on 或 systemctl enable atd
[root@centos7 temp]# at now +2 minutes #执行at并指定执行时刻为现在时间的后两分钟 at> echo hello world > /root/temp/file #手动输入命令并回车 at> <EOT> #ctrl+d 结束输入 job 9 at Thu Dec 22 14:05:00 2016 #显示任务号及执行时间 [root@centos7 temp]#
[root@centos7 temp]# atq 9 Thu Dec 22 14:05:00 2016 a root
[root@centos7 temp]# ls -l file -rw-r--r-- 1 root root 12 12月 22 14:05 file [root@centos7 temp]# cat file hello world [root@centos7 temp]#
[root@centos7 temp]# at 02:20pm tomorrow at> mkdir /root/temp/X at> <EOT> job 11 at Fri Dec 23 14:20:00 2016
[root@centos7 temp]# at -d 11 #删除11号任务(上例) [root@centos7 temp]# atq [root@centos7 temp]#
[root@centos7 temp]# cat test.txt echo hello world > /root/temp/file [root@centos7 temp]# at -f test.txt 5pm +2 days job 12 at Sat Dec 24 17:00:00 2016 [root@centos7 temp]# cat test.txt|at 16:20 12/23/16 job 13 at Fri Dec 23 16:20:00 2016
[root@centos7 temp]# ps -ef|grep [c]rond root 733 1 0 12月20 ? 00:00:00 /usr/sbin/crond -n
[root@centos7 ~]# crontab -l -u learner no crontab for learner [root@centos7 ~]#
[root@centos7 ~]# crontab -e */3 * * * * /usr/bin/ping -c1 10.0.1.252 &>> /root/252.log
[root@centos7 ~]# crontab -l */3 * * * * /usr/bin/ping -c1 10.0.1.252 &>> /root/252.log 30 2 * 1-5 2,5 /bin/bash /root/temp/backup.sh */2 12-14 * 3-6,9-12 1-5 /bin/bash /root/temp/refresh.sh
[root@centos7 ~]# crontab -r [root@centos7 ~]# crontab -l no crontab for root
[root@centos7 ~]# head -3 /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root [root@centos7 ~]# [root@centos7 ~]# echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin [root@centos7 ~]#
SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # run-parts 01 * * * * root run-parts /etc/cron.hourly 02 4 * * * root run-parts /etc/cron.daily 22 4 * * 0 root run-parts /etc/cron.weekly 42 4 1 * * root run-parts /etc/cron.monthly
# /etc/anacrontab: configuration file for anacron # See anacron(8) and anacrontab(5) for details. SHELL=/bin/sh PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root # the maximal random delay added to the base delay of the jobs RANDOM_DELAY=45 # the jobs will be started during the following hours only START_HOURS_RANGE=3-22 #period in days delay in minutes job-identifier command 1 5 cron.daily nice run-parts /etc/cron.daily 7 25 cron.weekly nice run-parts /etc/cron.weekly @monthly 45 cron.monthly nice run-parts /etc/cron.monthly
[root@centos7 temp]# cat /root/temp/ping252.sh #!/bin/bash ping -c1 10.0.1.252 &>> /root/temp/252.log
[root@centos7 temp]# cd /usr/lib/systemd/system [root@centos7 system]# cat ping252.service [Unit] Description=ping 252 [Service] Type=simple ExecStart=/root/temp/ping252.sh [root@centos7 system]#
[root@centos7 temp]# cd /usr/lib/systemd/system [root@centos7 system]# cat ping252.timer [Unit] Description=ping 252 every 30s [Timer] # Time to wait after enable this unit OnActiveSec=60 # Time between running each consecutive time OnUnitActiveSec=30 Unit=ping252.service [Install] WantedBy=multi-user.target [root@centos7 system]#
[root@centos7 system]# systemctl enable ping252.timer Created symlink from /etc/systemd/system/multi-user.target.wants/ping252.timer to /usr/lib/systemd/system/ping252.timer. [root@centos7 system]# systemctl start ping252.timer
#计时器
[root@centos7 system]# systemctl status ping252.timer
● ping252.timer - ping 252 every 30s
Loaded: loaded (/usr/lib/systemd/system/ping252.timer; enabled; vendor preset: disabled)
Active: active (waiting) since 五 2016-12-23 14:27:26 CST; 3min 42s ago
12月 23 14:27:26 centos7 systemd[1]: Started ping 252 every 30s.
12月 23 14:27:26 centos7 systemd[1]: Starting ping 252 every 30s.
#服务
[root@centos7 system]# systemctl status ping252
● ping252.service - ping 252
Loaded: loaded (/usr/lib/systemd/system/ping252.service; static; vendor preset: disabled)
Active: active (running) since 五 2016-12-23 14:35:38 CST; 2ms ago
Main PID: 11494 (ping252.sh)
CGroup: /system.slice/ping252.service
└─11494 /bin/bash /root/temp/ping252.sh
12月 23 14:35:38 centos7 systemd[1]: Started ping 252.
12月 23 14:35:38 centos7 systemd[1]: Starting ping 252...
[root@centos7 system]# systemctl disable ping252.timer Removed symlink /etc/systemd/system/multi-user.target.wants/ping252.timer. [root@centos7 system]# systemctl stop ping252.timer [root@centos7 system]#
Thu,Fri 2012-*-1,5 11:12:13 #表示2012年任意月份的1日和5日,如果是星期四或星期五,则在时间11:12:13执行 *-*-* *:*:00 #表示每分钟 *-*-* 00:00:00 #表示每天 *-01,07-01 00:00:00 #表示每半年 *:0/15 #表示每15分钟 12,14,13:20,10,30 #表示12/13/14点的10分、20分、30分 Mon,Fri *-01/2-01,03 *:30:45 #表示任意年份奇数月份的1日和3日,如果是周一或周五,则在每小时的30分45秒执行
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有