1、如何用shell脚本启动、关闭、重启、查看自己开发的程序的状态?方案二myshell.sh#!/bin/shSERVICE="fm_tuoguan_shell"PROCESS_STATUS="fm"CMD="/developer/robot-srpcs@node.abc.com:9902/1234567-padmin@cn888"start(){echo"starting..."nohup$CMD>$SERVICE.log2>&1&if[$?-ne0]thenecho"启动失败,请查看日志!"退出$?否则回显$!>$SERVICE.pidecho"startsuccess"fi}stop(){echo"stopping..."kill-9`cat$SERVICE.pid`if[$?-ne0]thenecho"stopfailed,maybe$SERVICEisn’trunning"exit$?elserm-rf$SERVICE.pidecho"停止成功"fi}restart(){stop&&start}status(){num=`ps-ef|grep$PROCESS_STATUS|grep-vgrep|wc-l`if[$num-eq0]thenecho"$SERVICEisn'trunning"elseecho"$SERVICEisrunning"fi}case$1instart)start;;stop)stop;;restart)restart;;status)status;;*)echo"Usage:$0{start|stop|restart|status}";;esacexit0设置可执行权限:chmod+xmyshell.shexecution:>shmyshell.shstart#relativepathstarting...startsuccess>sh/work/shelltask/myshell.shstart#absolute小路
