nginx相关

时间:2022-04-18 08:29:02
定时切割nginx日志
#!/bin/bash
#desc: cut nginx log
#this script run at 00:00 LOG_PATH='/usr/local/nginx/logs/';
LOG_BACK_PATH='/home/www/log/'$(date -d '-1 days' +'%Y/%m/');
mkdir -p $LOG_BACK_PATH;
cd $LOG_PATH && gzip access.log
mv access.log.gz $LOG_BACK_PATH'access_'$(date +'%d')'.log.gz';
kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`;

crontab -e

  * * * /bin/bash /bin/bash /root/tools/crond/nginxlog.sh >/dev/null >&

nginx管理脚本

#!/bin/bash
NGINXHOME=/usr/local/nginx
NGINX=$NGINXHOME/sbin/nginx RETVAL=
start(){
nohup $NGINX > /dev/null >& &
RETVAL=$?
if [ $? -eq ];then
echo 'start OK'
else
echo 'start FAILED'
fi
return $RETVAL
} stop(){
echo 'Stoping nginx...'
$NGINX -s stop
echo 'stop ok'
} restart(){
stop
sleep
start
} reload(){
$NGINX -s reload
echo 'reload ok'
} case "$1" in
start)
start;;
stop)
stop;;
restart)
restart;;
reload)
reload;;
chkconfig)
$NGINX -t;;
*)
echo "Usage: $NGINX (start|stop|reload|chkconfig)"
exit
esac