服务启动停止脚本

#!/bin/bash


case "$1" in
  start)
    echo  "starting......"
    if [ -n "$PID" ]; then
        echo "myread  is already running"
        exit
    else
        nohup your_cmd > message_queue_data.txt 2>&1 &
    fi
    ;;
  stop)
    echo  "stopping......"
    killall  myread
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"
esac
exit 0

你可能感兴趣的:(服务启动停止脚本)