这里注意以下-p后面没有空格直接加[my_pwd]
然后该sh脚本放入/log/sh/目录下并赋予执行权限,最后进入linux定时任务crond,加入以下脚本:
- # run-parts 每天5点02分执行databasebak.sh
- 01 * * * * root run-parts /etc/cron.hourly
- 02 4 * * * root run-parts /etc/cron.daily
- 22 4 * * 0 root run-parts /etc/cron.weekly
- 42 4 1 * * root run-parts /etc/cron.monthly
- 02 5 * * * root sh /log/sh/databasebak.sh
最后保存好后重启crond,service crond restart即可!
Linux中使用mysqldump对MySQL数据库进行定时备份
标签:定时任务 color efault art cal crond pwd mys database