rsync 서비스를 시작하는 스크립트 개발
우리는 rsync 서비스를 init에서 시작할 수 있습니다.디렉터리는요?우리가 스크립트만 쓰면 OK.
[root@zyj ~]# cat /etc/init.d/rsyncd
#!/bin/bash
#created by sanpang
#email:[email protected]
#home:lovers.blog.51cto.com
#qq:791880666
#function   This script is used to monitor if the file is a malicious changes
# Source function library.
. /etc/rc.d/init.d/functions
start(){
   if [ "`ps -ef | grep  "rsync --daemon"  | grep -v "grep" | wc -l`" -eq 1 ]; then
      echo "the rsync is started"
      action   "rsync start"      /bin/false
      exit 0
   fi
   rsync --daemon
   sleep 2
   if [ "`ps -ef | grep  "rsync --daemon"  | grep -v "grep" | wc -l`" -eq 1 ]; then
      action   "rsync start"      /bin/true
      exit 0
   fi
}
stop(){
   if [ "`ps -ef | grep  "rsync --daemon"  | grep -v "grep" | wc -l`" -eq 0 ]; then
      echo "the rsync is stopped"
      action   "rsync stop"       /bin/false
      exit 0
   fi
   pkill rsync
   sleep 2
   if  [ "`ps -ef | grep  "rsync --daemon"  | grep -v "grep" | wc -l`" -eq 0 ]; then
      action   "rsync stop"       /bin/false
   fi
}
restart(){
   if [ "`ps -ef | grep  "rsync --daemon"  | grep -v "grep" | wc -l`" -eq 0 ]; then
      rsync --daemon
      action    "rsync stop"       /bin/true
      exit 0
   fi
   if [ "`ps -ef | grep  "rsync --daemon"  | grep -v "grep" | wc -l`" -eq 1 ]; then
         rsync --daemon
      action   "rsync stop"       /bin/true
      action   "rsync start"       /bin/true
   fi
}
case $1 in
start|START)
    start
    RETVAL=$?
;;
stop|STOP)
    stop
    RETVAL=$?
;;
restart|RESTART)
    restart
    RETVAL=$?
;;
*)
     echo "you must input start|stop|restart"
;;
esac물론 rsync를 켜서 서비스를 시작할 수 있습니다. (아래 코드 추가)
#function   This script is used to monitor if the file is a malicious changes
# chkconfig: - 45 80
# description: rsync is used to monitor if the file is a malicious changes
# probe: true
# config: /etc/init.d/rsyncd
# Source function library.
. /etc/rc.d/init.d/functions그중 45는 서비스가 시작된 번호이고 80은 서비스가 정지된 번호입니다./etc/rc와는 주의하십시오.d/rc3.디렉터리의 서비스 번호 중첩
[root@zyj ~]# ls /etc/rc.d/rc3.d/
K01dnsmasq         K10cups        K69rpcsvcgssd  K85messagebus   K88wpa_supplicant  K99cpuspeed
K01smartd          K10psacct      K72autofs      K85rpcgssd      K89dund            K99lvm2-monitor
K02avahi-daemon    K10tcsd        K73ypbind      K85rpcidmapd    K89hidd            K99microcode_ctl이 테스트 결과는 다음과 같습니다.
[root@zyj ~]# /etc/init.d/rsyncd start
the rsync is started
rsync start [ ]
[root@zyj ~]# /etc/init.d/rsyncd stop
 
[root@zyj ~]# /etc/init.d/rsyncd start
rsync start [ ]
[root@zyj ~]# /etc/init.d/rsyncd restart
rsync stop [ ]
rsync start [ ]이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Tool 개발로 신경이 쓰인 워드를 정리해 간다· Form 응용 프로그램은 .NET Framework를 사용하고 있지만 .NET Framework 업데이트는 끝 .NET Core로 마이그레이션합니다. →.NET Core + Windows Form 어플리케이션에 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.