1.atd和crond两个任务管理程序的区别
at只会执行一次,而crond则是根据设定的时间周期进行循环执行
2.指定在每周周一09:00将时间写入testmail.txt文件中
[root@localhost ~]# touch /testmail.txt
[root@localhost ~]# crontab -e
0 9 * * 1 date >> testmail.txt
3.指定在每天凌晨4:00将该时间点之前的系统日志信息(/var/log/messages )备份到目录下/backup,备份后日志文件名显示格式logfileYY-MM-DD-HH-MM
[root@localhost ~]# mkdir /backup
0 4 * * * cp /var/log/messages /backup/logfile`date +\%y-\%m-\%d-\%H-\%M`
4、配置ntp时间服务器,确保客户端主机能和服务主机同步时间
server:ip a => 192.168.146.129
[root@localhost ~]# hostnamectl hostname server
[root@server ~]# vim /etc/chrony.conf
pool ntp.aliyun.com iburst
pool ntp.tecent.com iburst
allow 0.0.0.0/0
[root@server ~]# systemctl restart chronyd
[root@server ~]# systemctl disable --now firewalld
[root@server ~]# systemctl status firewalld
client:ip a =>192.168.146.131
[root@localhost ~]# hostnamectl hostname client
[root@client ~]# vim /etc/chrony.conf
pool 192.168.146.129 iburst
[root@client ~]# systemctl restart chronyd
[root@client ~]# date -s '10:00'
[root@client ~]# chronyc sources