- 工信部备案号 滇ICP备05000110号-1
- 滇公安备案 滇53010302000111
- 增值电信业务经营许可证 B1.B2-20181647、滇B1.B2-20190004
- 云南互联网协会理事单位
- 安全联盟认证网站身份V标记
- 域名注册服务机构许可:滇D3-20230001
- 代理域名注册服务机构:新网数码
1.mkfifo /map/logs/nginx/wireless/access.log
nohup cat /map/app/nginx-1.2.2/logs/error.log | /map/app/tools/cronolog-1.7.0/sbin/cronolog /map/logs/nginx/wireless/error/%Y/%m/%d/%H.log &
nohup cat /map/logs/nginx/wireless/access.log | /map/app/tools/cronolog-1.7.0/sbin/cronolog /map/logs/nginx/wireless/%Y/%m/%d/%H.log &
注意:在启动nginx前必须先启动cronolog,否则无法启动
2.把cronolog增加到nginx启动脚本中
脚本内容如下:
#!/bin/sh
#
# Comments to support chkconfig
#
# chkconfig: 2345 77 77
# Description: Startup script for nginx webserver
#
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
DAEMON=/map/app/nginx/sbin/$NAME
CONFIGFILE=/map/app/nginx/conf/nginx.conf
PIDFILE=/map/app/nginx/logs/$NAME.pid
SERVICENAME=/etc/init.d/nginxd-map
cronolog=/map/app/tools/cronolog-1.7.0/sbin/cronolog
ErrorLog=/map/app/nginx-1.0.6/logs/error.log
AccessLog=/map/logs/nginx/wireless/access.log
##红色部分是新增加的,检测文件是否是pipe类型,启动cronolog,杀掉cronolog,很简单,但是能够实现功能
d_mkfifo(){
[ ! -p $ErrorLog ] || [ ! -p $AccessLog ] && /bin/rm $ErrorLog $AccessLog && mkfifo $ErrorLog $AccessLog
}
cronolog_start()
{
#ps -ef|grep wireless|grep -v grep |awk '{print $2}'|xargs kill -9
nohup cat /map/app/nginx-1.0.6/logs/error.log | $cronolog /map/logs/nginx/wireless/error/%Y/%m/%d/%H.log &
nohup cat /map/logs/nginx/wireless/access.log | $cronolog /map/logs/nginx/wireless/%Y/%m/%d/%H.log &
}
cronolog_kill()
{
ps -ef|grep wireless|grep -v grep |awk '{print $2}'|xargs kill -9
}
# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0
d_start() {
d_mkfifo
cronolog_start
$DAEMON -c $CONFIGFILE || echo -n " already running"
}
d_stop() {
# kill -QUIT `cat $PIDFILE` || echo -n " not running"
cronolog_kill
killall nginx || echo -n " not running"
}
d_reload() {
kill -HUP `cat $PIDFILE` || echo -n " can't reload"
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."
;;
reload)
echo -n "Reloading $DESC configuration..."
d_reload
echo "reloaded."
;;
status)
pgrep -x $NAME > /dev/null && echo $NAME (pid `pgrep $NAME`) is running... || echo "$NAME is stoped."
;;
test|-t)
$DAEMON -t
;;
restart)
echo -n "Restarting $DESC: $NAME"
d_stop
sleep 2
d_start
echo "...done!"
;;
*)
echo "Usage: $SERVICENAME {start|stop|restart|reload|status|check}"
exit 3
;;
esac
exit 0
售前咨询
售后咨询
备案咨询
二维码
TOP