Rambo丶Q

导航

将命令添加到shell脚本中然后设置开机自启动

例如开机自启动nginx

编写一个脚本

#vi /usr/local/Monitor_nginx.sh

#!/bin/bash

if [ "$(ps -ef | grep "nginx: master process"| grep -v grep )" == "" ]

then

/usr/local/nginx/sbin/nginx

fi

#chmod u+x /usr/local/Monitor_nginx.sh

#vi /etc/rc.local

sh /usr/local/Monitor_nginx.sh

 

posted on 2013-12-13 16:05  Rambo丶Q  阅读(905)  评论(0编辑  收藏  举报