Nginx Diary cutting script, MySQL regular backup script

Source: Internet
Author: User

Most of the diary cutting and backup mechanisms are the same: The following 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.pid ' realizes automatic diary switching scheme via Nginx signal USR




MySQL Regular backup scenario:

#!/bin/sh

echo ' Start Backup db ... '

dm= ' Date +%a '

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 for Date:

Date +%y Year

Date +%m Month

Date +%d Day

Date +%a Week










This article from "East God to a dozen five" blog, declined reprint!

Nginx Diary cutting script, MySQL regular backup script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.