centos简单的mysql开机自启和自动保存脚本
来源:互联网 发布:移动硬盘怎么恢复数据 编辑:程序博客网 时间:2024/05/17 22:06
1.备份
写一个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看看备份出来的东西在不在?
自动备份
crontab -l
查看现有的多少任务
crontab -e
编辑定时任务每天23点10分备份
10 23 * * * /root/testdbbackup.sh
/sbin/service crond start //启动服务
/sbin/service crond stop //关闭服务
/sbin/service crond restart //重启服务
/sbin/service crond reload //重新载入配置
错误:/bin/sh^M: bad interpreter
是结尾的window下换行符导致,一般看不见,在vi里面检查一下结尾吧
2,开机启动
在/etc/rc.d/rc.local文件末尾添加
1、编辑rc.local文件
#vi /etc/rc.d/rc.local
2、加入如下启动命令
/etc/rc.d/init.d/mysqld start
aphce日志-----以下没有验证
access-log太大,CustomLog 前面全加#号
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的启动脚本末尾:
1 0 * * * /var/log/httpd/log-task.cron
- centos简单的mysql开机自启和自动保存脚本
- CentOS开机自动运行程序的脚本
- CentOS开机自动运行程序的脚本
- CentOS开机自动运行程序的脚本
- CentOS开机自动运行程序的脚本
- CentOS开机自动运行程序的脚本
- CentOS开机自动运行程序的脚本
- CentOS开机自动运行程序的脚本
- CentOS开机自动运行程序的脚本
- CentOS开机自动运行程序的脚本
- CentOS开机自动运行程序的脚本
- CentOS开机自动运行程序的脚本
- CentOS 开机自启动脚本
- CentOS 开机自启动脚本
- CentOS 开机自启动脚本
- CentOS 开机自启动脚本
- Centos 开机自动运行脚本
- centOS下开机自启动apache、mysql、samba、svn等服务的最简单方法
- NHibernate使用Criteria分页显示并返回记录总数
- poj3468 A Simple Problem with Integers
- Eclipse中搭建Qt开发环境http://blog.csdn.net/tykgls/article/details/5753705
- poj 1234 Ball Toss
- ubuntu下编译 jrtplib-3.9.1 和 jthread - 1.3.1
- centos简单的mysql开机自启和自动保存脚本
- 不开辟用于交换数据的临时空间完成字符串的逆序
- 对Objective-c委托的理解
- 类似微博的文件上传按钮file的美化
- 完成量实现线程同步
- 新浪微博错误代码大全
- TreeList + <select />+Ajax实现按部门选择员工
- 以前同事做的一款游戏还不错
- 基础算之五排序: 二叉排序树