Nginx diary cutting script and MySQL regular backup script
Most of the log cutting and backup mechanisms are the same: Below is the Nginx diary cutting script
#! /Bin/bash
Logpath = '/home/nginx/Log'
Nglogs = '/opt/nginx/logs
Mkdir-p $ logpath/$ (date + % Y)/$ (date + % m)
Mv $ nglogs/access. log $ logpath/$ (date + % Y)/$ (date + % m)/access. $ (date + % Y % m % d ). log
Mv $ nglogs/error. log $ logpath/$ (date + % Y)/$ (date + % m)/error. $ (date + % Y % m % d ). log
Kill-USR1 'cat/opt/nginx/logs/nginx. pid
Kill-USR 'cat/opt/nginx/logs/nginx. Pi' implements automatic switch of the diary through the nginx signal USR
MySQL regular backup solution:
#! /Bin/sh
Echo 'start backup db ...'
DM = 'date + %'
If [-f/opt/backup/xxx. $ DM. dmp]; then
Mv/opt/backup/xxx. dmp mv/opt/backup/xxx. dmp. old
Fi
Mysqldump-h ipaddress -- password = xxxx>/opt/backup/xxx. dmp
If [$? -Eq 0-a-f/home/smecloud/db_backup/kdrive. $ DM. dmp. old]; then
Rm/home/smecloud/db_backup/kdrive. $ DM. dmp. old
Echo 'backup xxx OK ....'
Fi
Echo 'end backup db ...'
Common Parameters of date:
Date + % Y
Date + % m month
Date + % d
Date + % a week
For more Nginx tutorials, see the following:
Deployment of Nginx + MySQL + PHP in CentOS 6.2
Build a WEB server using Nginx
Build a Web server based on Linux6.3 + Nginx1.2 + PHP5 + MySQL5.5
Performance Tuning for Nginx in CentOS 6.3
Configure Nginx to load the ngx_pagespeed module in CentOS 6.3
Install and configure Nginx + Pcre + php-fpm in CentOS 6.4
Nginx installation and configuration instructions
Nginx log filtering using ngx_log_if does not record specific logs
Nginx details: click here
Nginx: click here
This article permanently updates the link address: