nginx-start.sh 787 Bytes
#!/bin/bash

file_name="/var/log/nginx-run.log"
pid=0

proc_num()
{
        num=`ps -ef |  grep ".* 1 .*nginx: master process" | grep -v grep |  wc -l`
        return $num
}

proc_id()
{
        pid=`ps -ef |  grep ".* 1 .*nginx: master process" | grep -v grep | awk '{print $2}'`
}

proc_num
number=$?
echo $number >> $file_name
if [ $number -eq 0 ]
then
        source /etc/profile && source /root/.bash_profile && source /root/.bashrc
        export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64:/usr/lib/:/usr/lib64:$LD_LIBRARY_PATH
        export PATH=/usr/local/sbin:/usr/bin:/bin:/usr/local/bin:.:$PATH
        /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
        text=`date`
        hn=`hostname`
        proc_id
        echo ${pid}, `date` >> $file_name
fi