RHCE第一次作业

文章讲述了Linux系统中atd用于一次性任务调度,而crond用于周期性任务的自动化执行。示例展示了如何使用at命令安排未来时间的任务以及通过crontab配置每日凌晨4点的日志备份。此外,文中还详细描述了如何配置和连接两块网卡,使用绑定技术实现网络冗余,提高系统稳定性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.atd和crond两个任务管理程序的区别

atd单一执行的例行性任务: :单一执行的例行性工作:仅处理执行一次就结束了;

  crond循环执行的例行性任务:每隔一定的周期就需要执行一次。

  总的来说就是,at(一次性)crontab(周期性)。

2.2.指定在2023/03/29 19:00将时间写入testmail.txt文件中

#指定命令执行时间为2023/03/29 19:00
[root@333~]# at 19:00 032922    

#命令不能执行已经过的时间
at: refusing to create job destined in the past    

#指定命令执行时间为2023/08/26 21:00
[root@333~]# at 21:00 082622    
warning: commands will be executed using /bin/sh
at> echo `date` > /testmail.txt        
at> <EOT>

3.​3.指定在每天凌晨4:00将该时间点之前的系统日志信息备份到个目录下(/var/log/messages ),备份后日志文件名显示格式logfileYY-MM-DD HH-MM

[root@333 ~]# vim /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

00 04 * * *  root cp /var/log/messages  /logfile`date +%F%R`;echo > /var/log/messages
~             

4.

​4.在当前主机添加两块网卡,将两块网卡绑定实现网卡冗余操作。

网卡配置文件

[root@333 ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens160 

网卡配置

[root@333 ~]# 
 nmcli connection modify ens160 
 ipv4.addresses  192.168.58.129/24  
 ipv4.gateway  192.168.58.2      
 ipv4.dns 114.114.114.114  +ipv4.dns 8.8.8.8 
 ipv4.method manual connection.autoconnect yes 

[root@333 ~]# nmcli connection up ens160

查看网卡详情

[root@333 ~]# nmcli device status
 DEVICE      TYPE      STATE                   CONNECTION 
 ens160      ethernet  connected               ens160     
 virbr0      bridge    connected (externally)  virbr0     
 ens224      ethernet  disconnected            --         
 ens256      ethernet  disconnected            --         
 lo          loopback  unmanaged               --         
 virbr0-nic  tun       unmanaged               --     
 [root@333 ~]# nmcli device connect ens224 
 Device 'ens224' successfully activated with '2e25a153-2d98-4f51-bc8d-330a521f72f6'.
 [root@333 ~]# nmcli device connect ens256 
 Device 'ens256' successfully activated with '038b77e2-3ed1-4785-bbe6-b90718c1e697'.
 [root@333 ~]# cd /usr/share/doc/teamd/example_configs/
 [root@333 example_configs]# ll
 total 64
 -rw-r--r--. 1 root root 305 Jul 26  2020 activebackup_arp_ping_1.conf
 -rw-r--r--. 1 root root 465 Jul 26  2020 activebackup_arp_ping_2.conf
 -rw-r--r--. 1 root root 194 Jul 26  2020 activebackup_ethtool_1.conf
 -rw-r--r--. 1 root root 212 Jul 26  2020 activebackup_ethtool_2.conf
 -rw-r--r--. 1 root root 241 Jul 26  2020 activebackup_ethtool_3.conf
 -rw-r--r--. 1 root root 447 Jul 26  2020 activebackup_multi_lw_1.conf
 -rw-r--r--. 1 root root 285 Jul 26  2020 activebackup_nsna_ping_1.conf
 -rw-r--r--. 1 root root 318 Jul 26  2020 activebackup_tipc.conf
 -rw-r--r--. 1 root root  96 Jul 26  2020 broadcast.conf
 -rw-r--r--. 1 root root 209 Jul 26  2020 lacp_1.conf
 -rw-r--r--. 1 root root  98 Jul 26  2020 loadbalance_1.conf
 -rw-r--r--. 1 root root 140 Jul 26  2020 loadbalance_2.conf
 -rw-r--r--. 1 root root 183 Jul 26  2020 loadbalance_3.conf
 -rw-r--r--. 1 root root  93 Jul 26  2020 random.conf
 -rw-r--r--. 1 root root 244 Jul 26  2020 roundrobin_2.conf
 -rw-r--r--. 1 root root  97 Jul 26  2020 roundrobin.conf


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值