- 论坛徽章:
- 0
|
问题情况:
我运行起一个服务器,远程请求该服务器重设本机IP,调用的是我的shell脚本(脚本单独运行是可以重设本机IP的)。
脚本内容:- #!/bin/bash
- #set -u
- sleep 3
- if [ -n "$1" ] && [ -n "$2" ] && [ -n "$3" ]
- then
- sed -i 'd' /etc/sysconfig/network-scripts/ifcfg-eth0
- echo "DEVICE=eth0" >> /etc/sysconfig/network-scripts/ifcfg-eth0
- echo "ONBOOT=yes" >> /etc/sysconfig/network-scripts/ifcfg-eth0
- echo "BOOTPROTO=static" >> /etc/sysconfig/network-scripts/ifcfg-eth0
- echo "IPADDR=$1" >> /etc/sysconfig/network-scripts/ifcfg-eth0
- echo "NETMASK=$2" >> /etc/sysconfig/network-scripts/ifcfg-eth0
- echo "GATEWAY=$3" >> /etc/sysconfig/network-scripts/ifcfg-eth0
- #/etc/init.d/network restart
- echo "test" >> d.txt
- nohup service network restart >> a.txt &
- sleep 50
- echo $? >> b.txt
- ifconfig >> c.txt
- else
- echo "error,you haven't spercify ip or netmask or gateway"
- fi
复制代码 问题:
问题在于本机单独运行脚本可以,通过服务器程序调用脚本,就会在网卡重启时阻塞住:
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0:
翻了很多百度内容不知道是什么原因,望各位帮助一下。 |
|