为了在启动时首先延时8秒激活eth1
,再延时8秒激活eth2
,你可以通过创建两个systemd服务来分别控制这两个网络接口的激活。这里是具体如何设置这两个服务的步骤:
步骤1:创建第一个Systemd服务文件
首先创建控制eth1
的服务文件:
sudo vi /etc/systemd/system/eth1-wait.service
向文件中添加以下内容
[Unit]
Description=启动时延迟8秒激活eth1
After=network.target
[Service]
Type=oneshot
ExecStartPre=/bin/sleep 8
ExecStart=/usr/bin/nmcli con up uuid 558f737d-4e61-46f6-be12-b7a7d84c62c4
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
步骤2:创建第二个Systemd服务文件
接着创建控制eth2
的服务文件:
sudo vi /etc/systemd/system/eth2-wait.service
向文件中添加以下内容
[Unit]
Description=启动时延迟16秒激活eth2
After=eth1-wait.service
[Service]
Type=oneshot
ExecStartPre=/bin/sleep 8
ExecStart=/usr/bin/nmcli con up uuid 11b1299a-2f0d-466a-bd5f-f581ee72959d
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
注意这里的After=eth1-wait.service
指令,这确保了eth2
的服务在eth1
的服务之后启动。
步骤3:启用并启动服务
创建并保存两个文件后,启用并启动这两个服务以确保它们在启动时按顺序运行:
sudo systemctl enable eth1-wait.service
sudo systemctl start eth1-wait.service
sudo systemctl enable eth2-wait.service
sudo systemctl start eth2-wait.service
这将按照您设置的时间顺序(首先是8秒后激活eth1
,接着总共16秒后激活eth2
)配置您的系统在启动后激活这两个网络接口。