1.atd和crond两个任务管理程序的区别
atd是单一执行的例行性工作 :单一执行的例行性工作:仅处理执行一次就结束了;
crontab是循环执行的例行性工作:每隔一定的周期就需要执行一次。
2.指定在每周周一09:00将时间写入testmail.txt文件中
![](https://i-blog.csdnimg.cn/blog_migrate/0857c376984dfbba8b453b3a570a79a5.png)
创建testmail.txt文件,并查看
![](https://i-blog.csdnimg.cn/blog_migrate/c5458e5bb85c27cc639f085a104f58cc.png)
进入编辑cron任务模式(默认文字编辑器为vim,按a,i,o字母键进入编辑模式,后按ESC,结束编辑,进入命令模式,输入“:”进入末行模式,输入wq退出并保存)
后查看testmail.txt文件,写入成功
3.指定在每天凌晨4:00将该时间点之前的系统日志信息(/var/log/messages )备份到目录下/backup,备份后日志文件名显示格式logfileYY-MM-DD-HH-MM
![](https://i-blog.csdnimg.cn/blog_migrate/91f9562a31b9da04481b4caed0903070.png)
创建目录backup
![](https://i-blog.csdnimg.cn/blog_migrate/eba4e2e34d2337c16af18551e3c78124.png)
4、配置ntp时间服务器,确保客户端主机能和服务主机同步时间
在服务器准备工作
服务器:
#软件安装
[root@localhost ~]# yum install chrony -y
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
Error: There are no enabled repositories in "/etc/yum.repos.d", "/etc/yum/repos.d", "/etc/distro.repos.d".
[root@localhost ~]# rpm -qa | grep chrony
chrony-4.2-1.el9.x86_64
#设置允许哪个客户端可以访问该服务器
[root@localhost ~]# vim /etc/chrony.conf
[root@localhost ~]# grep ^allow /etc/chrony.conf
allow 0.0.0.0/0
#重启
[root@localhost ~]# systemctl restart chronyd
#关闭防火墙
[root@localhost ~]# systemctl disable --now firewalld
客户机:
#软件安装
[root@localhost ~]# rpm -qa | grep chrony
chrony-4.2-1.el9.x86_64
#设置时间服务器的服务端名字
[root@localhost ~]# vim /etc/chrony.conf
[root@localhost ~]# grep ^pool /etc/chrony.conf
pool 192.168.174.130 iburst
#重启
[root@localhost ~]# systemctl restart chronyd
[root@localhost ~]# chronyc sources
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 192.168.174.130 2 6 17 8 +35us[ +98us] +/- 26ms