ubuntu設定redis開機啟動

來源:互聯網
上載者:User

ubuntu設定redis開機啟動 今天,沉住氣,了結了redis開機啟動的遺憾。對我來說,這是個不小小的工作,如果要完全弄懂的話。困難如下:  www.2cto.com    1---redis啟動指令碼,及shell指令碼的編寫。   2---linux服務機制,那些進程會如何開機啟動關閉。   其中也的確遇到了一些困難。好在今天狀態不錯,都一一解決了。所以,流水記錄如下。  www.2cto.com  啟動shell指令碼如下,當然也是參考的他人的。 [cpp] #! /bin/sh    server_dir=/opt/redis-2.6.10  server_name=redis-server  demo=$server_dir/src/$server_name  configuration_file=$server_dir/redis.conf  pid_file=$server_dir/pid/redis.pid      start()  {    #檢測server是否存在,且有執行許可權    if test -x $demo      echo "Starting redis"     then      #執行啟動命令,返回執行結果      if $demo $configuration_file       then        echo  "OK"      else        echo  "Failed"      fi    else      echo "Could not find redis server ($demo)"    fi  }    stop()  {    #檢測pid檔案是否存在,如果存在則表明正在運行    if test -e $pid_file    then       echo "Stopping redis"      #pid檔案中只儲存了進程號,所以直接得到進程號殺死即可      if kill `cat $pid_file`      then        echo "OK"      else        echo "Failed"      fi    else      echo "No server is running!"      exit 0    fi  }     restart()  {    stop    start  }      #檢測輸入的命令  case $1 in     start)      start      ;;    stop)      stop      ;;    restart|reload)      restart      ;;    *)      echo  "Bad command"      exit 1  esac    exit 0  遇到的問題:1--shell case 的使用 2--shell test 命令的使用 3--shell 空格(賦值/判斷)  如果經過測試後指令碼通過,則可以進行下一項任務:設定指令碼開機啟動執行。 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.