shell脚本管理服务
本地检查端口方法 netstat -lntup ss -lntup lsof i:port 远程检查端口方法 telnet ip port /nc ip port /nmap 进程检查 ps -ef/ ps aux 测试连接 ping -c1 -i1 -W1 ip|url /curl /wget -q --spider ip|url centos6 mv rsyncd.sh /etc/init.d/ chmod +x /etc/init.d/rsyncd.sh chkconfig --add rsyncd.sh cat rsyncd.sh #!/bin/bash # chkconfig: 2345 99 98 choice=$1 path=/var/run/rsyncd.pid case "$choice" in start) [ -f $path ] || rsync --daemon ;; stop) [ -f $path ] && kill `cat $path` ;; restart) [ -f $path ] && kill `cat $path` sleep 1 rsync --daemon ;; *) echo error esac 可以使用 chkconfig 服务名称 off/on 进行管理 centos7 [root@manager ~]# cat /usr