再来1章linux 系列-11 系统的延迟任务及定时任务 at ,crontab,mail;/etc/at.allow,/etc/at.deny
学习目标:
- 实验
- at ,crontab,mail;/etc/at.allow,/etc/at.deny
- 实验需求
- 实验配置内容和分析 (每一个设备的每一步操作)
- 实验结果验证
- 其他
学习内容:
- 实验
- 实验需求
- 实验配置内容和分析 (每一个设备的每一步操作)
- 实验结果验证
- 其他
目录
学习目标:
学习内容:
1.实验
2.实验需求
3.实验配置内容和分析 (每一个设备的每一步操作)
延迟实验
at
优化--名单
定时任务
系统级别的周期任务-->优化-名单
4.实验结果验证
延迟实验
MAIL;at
crontab(定时任务
延时优化--名单
5.其他
学习时间:
学习产出:
1.实验
at ,crontab,mail;/etc/at.allow,/etc/at.deny
2.实验需求
图+文字
3.实验配置内容和分析 (每一个设备的每一步操作)
延迟实验
wacth -n 1 "ls -Rl /mnt/"
systemctl status atd.serviceat 19:18
at> touch /mnt/file{1..5}
at> <EOT>
at now+5min
at -l
at -c 2
at -l
at -r 2
vim at.sh
at now+5min <<EOF
touch /mnt/file{1..5}
date
EOF
cat -b at.sh
sh at.sh
at
cd /root/桌面/
cd /root
mkdir /rhel9
mount /dev/sr0 /rhel9/
ls /rhel9/
cd /etc/yum.repos.d/(ls redhat.repo)
vim root.repo
[AppStream]
name=AppStream
baseurl=file:///rhel9/AppStream
gpgcheck=0
[BaseOS]
name=BaseOS
baseurl=file:///rhel9/BaseOS
gpgcheck=0
dnf install postfix.x86_64
dnf install s-nail.x86_64
systemctl enable --now postfix
watch -n 1 mail
at now+1min
date
ctrl +d
mail
>N 1
q
at now+1min
touch /mnt/file
<EOT>
ls /mnt/
at -m now+1min
rm -fr /mnt/*
<EOF>
ls /mnt/
at -l
10 Tue Apr 22 19:45:00 2025 a root
at -d 10
at -V
at -v now+1min
at -l
at -c 11
vim work
date
rm -fr /mnt/*
at now+lmin -f work
at now+2hours
at -v now+2hours
cd /root/桌面
优化--名单
useradd timinglee
at now+1min
useradd timingleell /etc/at.deny
vim /etc/at.deny
timinglee
su - timinglee
at now+1min
su - root
touch /etc/at.allow
vim /etc/at.allow
timinglee
-------------
useradd leeecho lee > /etc/cron.deny
cat /etc/cron.denytouch /etc/cron.allow
echo lee > /etc/cron.allow
cat /etc/cron.allow
echo timinglee >> /etc/cron.allowcrontab -e
rm -fr /etc/cron.allow
> /etc/cron.deny
定时任务
systemctl status crond. service
watch -n1 ls -1 /mnt/
field allowed values minute hour0-590-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sumday, or use names)
crontab -u root -e
***** touch /mnt/file{1..5}
rm -fr /mnt/*
cat /var/spool/cron/root
crontab -l
crontab -r -u root
crontab -l
crontab -ri -u root
crontab -l
系统级别的周期任务-->优化-名单
cd/var/spool/cron/
cd etc/cron.
cron.d/
cron.daily/
cron.hourly/
cron.monthly/
cron.weekly/
watch -n1 ls /media/ -l
cd /etc/cron.d
vim timinglee
* * * * * root touch /media/leet{1..5}ls -ld /etc/cron.d
rm -fr /etc/cron.d/timinglee
useradd leeecho lee > /etc/cron.deny
cat /etc/cron.deny
touch /etc/cron.allow
echo lee > /etc/cron.allow
cat /etc/cron.allow
echo timinglee >> /etc/cron.allow
crontab -e
rm -fr /etc/cron.allow
/etc/cron.deny
4.实验结果验证
延迟实验
MAIL;at
8
crontab(定时任务
延时优化--名单
5.其他
参数 | 说明 | 示例 | |
---|---|---|---|
-u user | 指定操作用户的时程表,需root权限 | crontab -u root -l | |
-e | 启动默认编辑器(如Vim)编辑当前用户的时程表 | crontab -e | |
-l | 列出当前用户的时程表内容 | crontab -l | |
-r | 删除当前用户的所有定时任务(无确认提示) | crontab -r | |
-i | 与-r 配合使用,删除前要求用户确认 | crontab -i -r | |
file | 从指定文件导入定时任务(需直接跟在命令后,无参数前缀) | crontab /path/to/tasks.conf |
字段名称 | 取值范围 | 特殊说明 | 示例 | |
---|---|---|---|---|
分钟 | 0-59 | 整点或具体分钟 | 30 表示30分 | |
小时 | 0-23 | 24小时制 | 2 表示凌晨2点 | |
日期 | 1-31 | 无0值,按月份实际天数调整 | 15 表示15号 | |
月份 | 1-12 | 数字或三字母英文缩写(如Jan ) | 6 表示6月 | |
星期 | 0-7(0和7均为周日) | 数字或三字母英文缩写(如Mon ) | 1 表示周一 |
符号 | 作用 | 规则说明 | 示例 | |
---|---|---|---|---|
* | 匹配任意值 | 字段未限制时默认使用 | * * * * * 每分钟执行 | |
, | 指定多个离散值 | 用逗号分隔不连续的值 | 1,3,5 表示第1/3/5小时 | |
- | 定义连续范围 | 支持跨天(如小时字段18-2 表示18点到次日2点) | 9-18 表示9点到18点 | |
/ | 指定步长 | 需搭配* 或范围使用,起始点默认为字段最小值 | */15 表示每15分钟一次 |
参数 | 说明 | 示例 | |
---|---|---|---|
-m | 任务完成后发送邮件通知用户,即使无输出 | at -m now + 1 hour | |
-l | 列出当前用户的所有计划任务(同atq ) | at -l | |
-d <ID> | 删除指定ID的任务(同atrm ) | at -d 3 | |
-f <文件> | 从文件读取要执行的命令(替代交互式输入) | at -f script.sh 09:00 | |
-v | 显示任务将被执行的具体时间 | at -v 15:00 | |
-c <ID> | 查看指定ID任务的具体内容 | at -c 2 |
学习时间:
学习时间为学习时间
学习时间 | 筋肉人 |
为学习时间 | future |
内容为笔记【有时比较抽象,有时比较过于详细,请宽恕。作者可能写的是仅个人笔记,筋肉人future】
学习产出:
绿色框为logo
画工
。puppy-CSDN博客。puppy擅长计算机网络,python,软件,等方面的知识
https://blog.csdn.net/2301_79807099?type=blog
再来1章linux 系列-10 磁盘管理 MBR,PV,VG,LV,软链接硬链接)分区挂载mount/umount;remount;fuser生成虚拟磁盘文件--ddswapmadafind-CSDN博客
再来1章linux 系列-9 软件管理 rpm dnf 库搭建 epel-CSDN博客
再来1章linux 系列-8 网络管理 ip add/del nmcli ping wegt curl-CSDN博客
再来1章linux 系列-7 文件传输scp,rync,tar-CSDN博客
再来1章linux 系列-6 进程管理 的详细图文解释+实验【chatter,lsatter,ps,pgrep,top,pgrep,pidof,nicerenice,kill,system进线程】-CSDN博客
再来1章linux 系列-5.2 权限管理的实验详细1Sticky Bit2 SGID (Set GID)3 SUID (Set UID)4. chmod 5.ACL 6.chown-CSDN博客
再来1章linux5.1[权限rwx,文件和目录,权限信息,文件类型 ,ugo,ls,chown,chgrp.:-R chmod umask souce etc/profile etc/bashrc等-CSDN博客
再来1章linux 系列-0. C语言过、Java半静对、Python纯动和C++对+C-CSDN博客
再来1章linux 系列-0.Linux的特点-CSDN博客
- 技术笔记 1遍
- 有错误请指出,作者会及时改正