Skip to content

Instantly share code, notes, and snippets.

@metacoma
Created January 14, 2014 20:41
Show Gist options
  • Save metacoma/8425286 to your computer and use it in GitHub Desktop.
Save metacoma/8425286 to your computer and use it in GitHub Desktop.
#!/bin/sh
IP=172.16.128.1
SOURCE_CMD="ssh root@${IP} ps w"
#SOURCE_CMD="cat /tmp/tpl"
while :; do
ping -W1 -c1 ${IP} && break
done
while :; do
echo "check port"
echo "" | nc $IP 22 && break
sleep 1
done
pids=`$SOURCE_CMD | egrep -v '(\[|syslogd|klogd|netifd|dropbear)|(PID)|S init' | awk '{print $1}'`
echo $pids
if [ -n "${pids}" ]; then
ssh root@$IP kill ${pids}
fi
sleep 3
ssh root@$IP ps w
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment