linux 未识别的服务

给linux添加服务的步骤: 第一:编写服务脚本,命名为:testService  

  1. start()  
  2. {  
  3.     echo “start testService”  
  4.     /usr/local/bin/testService &   #可执行文件路径  
  5.     exit 0;  
  6. }  
  7. stop()  
  8. {  
  9.     echo -n “stop testService”  
  10.     if pkill testService  
  11.         then  
  12.         echo  ”              [ok]”  
  13.     else  
  14.         echo  ”              [failed]”  
  15.     fi  
  16. }  
  17. case “$1” in  
  18. start)  
  19.     start  
  20.     ;;  
  21. stop)  
  22.     stop  
  23.     ;;  
  24. restart)  
  25.     stop  
  26.     start  
  27.     ;;  
  28. *)  
  29.     echo “usage: $0 start|stop|restart”  
  30.     exit 0;  
  31. esac  
第二:把文件testService拷贝到/etc/init.d/目录下面  第三:就可以执行service testService start (stop 、 restart)来操作文件了。   但是今天遇到意见郁闷的事, 第一:检查文件是否在/usr/init.d/目录下面,文件确确实实存在 第二:执行service testService start ,报错,未识别的服务, 第三:检查脚本文件,是否正确,确确实实正确,执行其他服务都能执行   检查了下/usr/init.d/testServic的权限,如下:  
  1. [root@~]# service testService start  
  2. uapd: 未被识别的服务  
  3. [root@~]# ll /etc/init.d/testService                  #检查权限  
  4. ———- 1 root root 1025 08-30 17:47 /etc/init.d/testService #文件权限  
  5. [root@~]#   
  6. [root@~]# chmod 033 /etc/init.d/testService           #设置文件权限  
  7. [root@~]# service uapd start  
  8. start testService  [确定]  
  9. [root@~]#   
解决: 1、先检查了文件的权限,此时即使文件在/etc/init.d/testService目录下,仍然不能使用服务 2、设置了文件权限后,服务能够正常识别了
]]>

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注