eth0 UP时运行脚本 [英] Run script when eth0 UP
本文介绍了eth0 UP时运行脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在Centos 6.8的启动 eth0 界面之后运行脚本
I need to run a script after the start eth0 interface in Centos 6.8
当我使用 ppp0 进行操作时,我在此处放置了脚本:/etc/ppp/ip-up.local
,并且可以正常工作.如何使用 eth0 做同样的事情?
When I do it with ppp0 I put scripts here: /etc/ppp/ip-up.local
and it works.
How to do the same with eth0?
我试图将脚本放入差异文件中,检查权限,但是不起作用.
I tried to put scripts in difference files, checking permissions, but does not work.
我尝试放置脚本的文件:
Files that I tried to put scripts:
**/etc/sysconfig/network-scripts/ip-up.local
/etc/sysconfig/network-scripts/ifup-local
/sbin/ifup-pre-local
/sbin/ifup-local
/sbin/ip-up.local**
推荐答案
使用 NetworkManager ,我们可以创建文件/etc/NetworkManager/dispatcher.d/15-my-ip-本地
,它将运行必要的脚本
Using NetworkManager, we can create a file /etc/NetworkManager/dispatcher.d/15-my-ip-up-local
that will run the necessary scripts
#!/bin/bash
### /bin/bash /etc/NetworkManager/dispatcher.d/15-my-ip-up-local
if [ "$1" = "eth0" ] && [ "$2" = "up" ]; then
echo run my scripts in up
else
echo DO_NOTHING
fi
这篇关于eth0 UP时运行脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文