mysql开机启动脚本_centos简单的mysql开机自启和自动保存脚本
1.備份
寫一個(gè)testdbbackup.sh文件
------------------------
#!/bin/sh
DBName=test
DBUser=root
DBPasswd=root
BackupPath=/root/ db
mysqldump -u$DBUser -p$DBPasswd $DBName > /root/db/`date -I`_$DBName.sql
#刪除7天以前的
#find /root/db -name $DBName.sql -mtime +7 -exec rm {} ;
--------------------------
./testdbbackup.sh看看備份出來的東西在不在?
自動(dòng)備份
crontab -l
查看現(xiàn)有的多少任務(wù)
crontab -e
編輯定時(shí)任務(wù)每天23點(diǎn)10分備份
10 23 * * * /root/testdbbackup.sh
/sbin/service crond start //啟動(dòng)服務(wù)
/sbin/service crond stop //關(guān)閉服務(wù)
/sbin/service crond restart //重啟服務(wù)
/sbin/service crond reload //重新載入配置
錯(cuò)誤:/bin/sh^M: bad interpreter
是結(jié)尾的window下?lián)Q行符導(dǎo)致,一般看不見,在vi里面檢查一下結(jié)尾吧
2,開機(jī)啟動(dòng)
在/etc/rc.d/rc.local文件末尾添加
1、編輯rc.local文件
#vi /etc/rc.d/rc.local
2、加入如下啟動(dòng)命令/etc/rc.d/init.d/mysqld start
aphce日志-----以下沒有驗(yàn)證
access-log太大,CustomLog 前面全加#號(hào)
httpd-error.log 太大,修改LogLevel warn 為err
要不然
#!/bin/bash
YESTERDAY=`date -d yesterday +%Y%m%d`
/usr/bin/gzip -c /var/log/httpd/access_log>/var/log/httpd/access${YESTERDAY}.log.gz
>/var/log/httpd/access_log
/usr/bin/gzip -c /var/log/httpd/error_log>/var/log/httpd/error${YESTERDAY}.log.gz
>/var/log/httpd/error_log
chmod u+x /var/log/httpd/log-task.cron
測試:
/var/log/httpd/log-task.cron
crontab -e
然后將以下的的代碼拷貝加入到cron的啟動(dòng)腳本末尾:
1 0 * * * /var/log/httpd/log-task.cron
分享到:
2012-05-28 15:01
瀏覽 504
評(píng)論
與50位技術(shù)專家面對(duì)面20年技術(shù)見證,附贈(zèng)技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的mysql开机启动脚本_centos简单的mysql开机自启和自动保存脚本的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 什么是贷款程序 贷款的审查和发放
- 下一篇: mysql 临时文件目录_MySQL数据