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 8 开机启动Nginx脚本
开机自启动,脚本
CentOS 7.2 设置脚本在服务器开机时自动启动,CentOS 7.2 设置脚本在服务器开机时自动启动.
CentOs7下 mysql5.7自动备份数据库脚本
rocketmq设置开机启动脚本
centos设置tomcat开机自启动
CentOS MySQL启动和关闭命令
Centos 7.4 配置 oracle 自启动,使oracle可以随操作系统开机启动
centos 7 MySQL8 离线一键自动安装脚本
在CentOS7下,设置ssh自启动,修改ssh监听端口
centos7.9 自动安装mysql8.0.33,附带脚本
当出现多个springboot项目需要启动的时候,可以使用脚本启动的方式。这在springcloud项目的开发测试阶段尤为有用。以下展示启动脚本示例,过程中遇到的问题,以及相关的解决办法。 1、启动脚本 #!/bin/sh export ...
centos7.0安装mysql centos7.0安装mysql centos7.0安装mysql
CentOS 7不带Mysql数据库了,默认的数据库是MariaDB(Mysql的一个分支)。 可以按照以下步骤手动安装Mysql数据库。 1. 下载rpm安装文件 wget http://repo.mysql.com/mysql-community-release-el7.rpm 2. 执行rpm...
CentOS 7.6+mysql5.7 设置mysql开机自启动。
文件夹里包含mysql8安装的依赖文件,perl rpm文件和mysql rpm文件,直接执行脚本mysql8.sh install安装或者mysql8.sh uninstall卸载,基本上是一键安装或者卸载了,只包含了安装,不包含启动,自己 systemctl start ...
CentOS安装MySQL5.7,带部分截图
原文:https://blog.csdn.net/m0_37814112/article/details/120220219 说明:centos7内核一键升级到5.4.13版本自动化脚本
本篇文章主要介绍了Centos7开机启动自己的脚本的方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下。
Centos6.5下自动加载网卡,请把脚本复制到/etc/init.d/文件夹下,并chmod 555 0.sh设置运行权限