標籤:date mysql find roc bash master website ack logs
備份網站程式
#!/bin/bash/bin/tar czf /mnt/backup_website/web_$(date +%Y%m%d_%H%M%S).gz.tar /mnt/wwwroot/webcd /mnt/backup_websitefind . -mtime +1 -name "*20[1-9][3-9]*" | xargs rm -fexit 0
備份資料庫
#!/bin/bash/bin/tar czf /mnt/backup_website/newjiagu_$(date +%Y%m%d_%H%M%S).gz.tar /mnt/wwwroot/newjiagucd /mnt/backup_websitefind . -mtime +1 -name "*20[1-9][3-9]*" | xargs rm -fexit 0[[email protected] shell]# cat backup_database.sh #!/bin/bashmysqldump -uroot -proot web > /home/database/web_$(date +%Y%m%d_%H%M%S).sqlcd /home/databasefind . -mtime +7 -name "*20[1-9][3-9]*" | xargs rm -fexit 0
切割日誌
#!/bin/bashLOGS_PATH=/home/wwwlogsYESTERDAY=$(date -d "yesterday" +%Y%m%d)mv ${LOGS_PATH}/access.log ${LOGS_PATH}/${YESTERDAY}.logkill -USR1 `ps axu | grep "nginx: master process" | grep -v grep | awk ‘{print $2}‘`cd ${LOGS_PATH}find . -mtime +7 -name "*20[1-9][3-9]*" | xargs rm -fexit 0
常用的shell(備份資料庫、備份網站、切割訪問日誌)