2016年4月14日 星期四

Redmine 啟動背景執行 Shell Script

最近VirtualPC再Windows重啟後透過排程設定背景執行,所以往常Redmine手動啟動變得沒有途徑可以輸入,寫入vc.local啟動命令列方式看來也殘念了,找到以下這腳本目前運作OK~~

#!/bin/bash # Modify it to your configuration DIR=/var/www/html/redmine/ # Start Redmine in daemon mode. start(){ cd $DIR ruby script/rails server webrick -e production -d > log/redmine.log } # Stop Redmine daemon stop(){ RUBYPID=`ps aux | grep "rails" | grep -v grep | awk '{print $2}'` if [ "x$RUBYPID" != "x" ]; then kill -2 $RUBYPID fi } # Check if Redmine is running status(){ RUBYPID=`ps aux | grep "rails" | grep -v grep | awk '{print $2}'` if [ "x$RUBYPID" = "x" ]; then echo "* Redmine is not running" else echo "* Redmine is running" fi
}

case "$1" in
  start)
    start
    status
    ;;
  stop)
    stop
    sleep 2
    status
    ;;
  status)
    status
    ;;
  restart|force-reload)
    stop
    start
    ;;
  *)
    echo "Usage: $0 {start|stop|restart|force-reload|status}"
    exit 1
esac

沒有留言: