- # kill all old instances
- if [ $instances -gt 10 ] ; then
- ps -C sshd -o pid=,start_time=,command= |
- grep "$slice \[priv\]" |
- while read pid start_time command ; do
- start_time=$(date -d "$start_time" +%s)
- min=$(date -d "6 hours ago" +%s)
- if [ $start_time -lt $min ] ; then
- echo "* Killing $slice sshd pid $pid"
- kill -9 $pid
- fi
- done
- fi
+ # kill all old instances
+ if [ $instances -gt 10 ] ; then
+ ps -C sshd -o pid=,start_time=,command= |
+ grep "$slice \[priv\]" |
+ while read pid start_time command ; do
+ start_time=$(date -d "$start_time" +%s)
+ min=$(date -d "6 hours ago" +%s)
+ if [ $start_time -lt $min ] ; then
+ echo "* Killing $slice sshd pid $pid"
+ kill -9 $pid
+ fi
+ done
+ fi
+ done
+}
+
+kill_nm_inslice(){
+ pids=$(vps aux | awk '$1 != "root" && $14 == "/usr/share/NodeManager/nm.py" {print $2}')
+ for pid in $pids ; do
+ line=$(vps aux | grep $pid)
+ echo NM found in slice. Killing PID $pid
+ echo $line
+ kill -9 $pid
+ done
+}
+
+kill_nonroot_nm(){
+ # For whatever reason, Some NM's, after fork and chcontext...don't chcontext. Kill them.
+ pids=$(ps aux | awk '$1 != "root" && $12 == "/usr/share/NodeManager/nm.py" {print $2}')
+ for pid in $pids ; do
+ line=$(ps aux | grep $pid)
+ echo NM found not belonging to root. Killing PID $pid
+ echo $line
+ kill -9 $pid