mysqldump 在 crontab 中不起作用 [英] mysqldump doesn't work in crontab

查看:56
本文介绍了mysqldump 在 crontab 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在备份 mysql 数据库的 crontab(ubuntu 服务器)中添加一个 cronjob.

I'm trying to add a cronjob in the crontab (ubuntu server) that backups the mysql db.

以 root 身份在终端中执行脚本效果很好,但插入到 crontab 中没有任何反应.我试图每分钟运行一次,但文件夹/var/db_backups 中没有出现任何文件.

Executing the script in the terminal as root works well, but inserted in the crontab nothing happens. I've tried to run it each minutes but no files appears in the folder /var/db_backups.

(其他定时任务运行良好)

(Other cronjobs work well)

这是cronjob:

* * * * * mysqldump -u root -pHERE 这是我的密码--all-databases |gzip >/var/db_backups/database_`date +%d%m%y`.sql.gz

* * * * * mysqldump -u root -pHERE THERE IS MY PASSWORD --all-databases | gzip > /var/db_backups/database_`date +%d%m%y`.sql.gz

可能是什么问题?

推荐答案

你需要用

mysqldump -u 'username' -p'password' DBNAME > /home/eric/db_backup/liveDB_`date +\%Y\%m\%d_\%H\%M`.sql

这篇关于mysqldump 在 crontab 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆