问题
I need to run a script after the start eth0 interface in Centos 6.8
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**
回答1:
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
来源:https://stackoverflow.com/questions/38523734/run-script-when-eth0-up