当前位置: 移动技术网 > IT编程>网络>Dos/Bat > 用bat实现定时执行任务的批处理文件

用bat实现定时执行任务的批处理文件

2017年12月12日  | 移动技术网IT编程  | 我要评论
@echo off
set txt1=%date:~0,4%
::当前年
set txt2=%date:~5,2%
::当前月
set txt3=%date:~8,2%
::当前日
set txt4=%time:~0,2%
::当前小时
set txt5=%time:~3,2%
::当前分钟
set txt6=%time:~6,2%
::当前秒
set date=%txt1%%txt2%%txt3%
set time=%txt4%%txt5%%txt6%
echo --------------------------------------------------
echo -------------正在执行mysql数据库备份--------------
echo --------------------------------------------------
echo ...
echo ...
echo 导出database...
if exist %date%.sql del %date%.sql
c:\progr*\mysql\bin\mysqldump --add-drop-table -c -u root -p-h  localhost  dbname >e:\%date%.sql
echo ...
echo ...
if exist dump%date%.7z del dump%date%.7z
echo 压缩文件...
7za.exe a -t7z dump%date%.7z %date%.sql -mx9
echo ...
echo ...
echo 删除临时文件
del %date%.sql
echo ...
echo ...
echo 备份完成!
pause

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网