[shell]管理 Sphinx 啓動|中止|從新生成索引的腳本

對於啓動sphinx的服務,能夠直接輸入以下命令app

 /usr/bin/searchd -c /etc/sphinx/sphinx.confspa

<!-- /usr/local/bin/searchd -c /etc/sphinx.conf -->.net

下面是寫成腳本的方式方便之後維護rest

由於工做須要,因此把管理 Sphinx 的相關操做寫成一個管理腳本,方便平常使用。blog

 

[plain]  view plain  copy
 
  1. #!/bin/sh  
  2. #file: /usr/local/bin/sphinx  
  3. #  
  4. #~ power by yagas60@21cn.com  
  5. #~ blog: http://blog.csdn.net/yagas  
  6.   
  7.   
  8. . /etc/rc.d/init.d/functions  
  9.   
  10. appName="Sphinx"  
  11.   
  12. stop(){  
  13.     /usr/local/bin/searchd -c /usr/local/coreseek/etc/sphinx.conf --stop > /dev/null 2>&1   
  14.         ret=$?  
  15.         if [ $ret -eq 0 ]; then  
  16.             action $"Stoping $appName: " /bin/true  
  17.         else  
  18.             action $"Stoping $appName: " /bin/false  
  19.         fi  
  20.     return $ret  
  21. }  
  22.   
  23. start(){  
  24.     /usr/local/bin/searchd -c /usr/local/coreseek/etc/sphinx.conf > /dev/null 2>&1   
  25.         ret=$?  
  26.         if [ $ret -eq 0 ]; then  
  27.             action $"Starting $appName: " /bin/true  
  28.         else  
  29.             action $"Starting $appName: " /bin/false  
  30.         fi  
  31.     return $ret  
  32. }  
  33.   
  34. indexer(){  
  35.         /usr/local/bin/indexer -c /usr/local/coreseek/etc/sphinx.conf --all > /dev/null 2>&1  
  36.     ret=$?  
  37.         if [ $ret -eq 0 ]; then  
  38.             action $"$appName making index: " /bin/true  
  39.         else  
  40.             action $"$appName making index: " /bin/false  
  41.         fi  
  42.         return $ret  
  43. }  
  44.   
  45.   
  46. case $1 in  
  47.     restart)  
  48.     stop  
  49.     indexer  
  50.     start  
  51.     ;;  
  52.   
  53.     stop)  
  54.     stop  
  55.     ;;  
  56.       
  57.     start)  
  58.     start  
  59.     ;;  
  60. esac  
  61.   
  62. exit 0  


使用方法:ip

 

啓動服務 sphinx startget

中止服務 sphinx stopit

從新生成搜索 sphinx restartio

 

文章摘自http://blog.csdn.net/yagas/article/details/6718532function

相關文章
相關標籤/搜索