stop.sh 442 字节
#!/bin/bash

pwd=`pwd`
target=`basename $pwd`

# kill
pid=`ps -C ${target} -o pid=`
if [ -n "$pid" ]; then

  echo "Stopping old version, PID: ${pid}"
  if [ "$1" = "-f" ]; then
    # force shutdown
    echo "Force shutdown..."
    kill -9 $(ps -C ${target} -o pid=)
  else
    kill -9 $(ps -C ${target} -o pid=)
  fi

  # wait for program to stop
  pid=`ps -C ${target} -o pid=`
  while [ -n "$pid" ]; do
    sleep 1
  done

fi

echo "Done"