mysqldump在cron中不起作用 [英] mysqldump is not working in cron

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

问题描述

首先,我用以下文本创建了.my.cnf in /home/username/:

First, I created .my.cnf in /home/username/ with the following text:

[client] user = sample_user password = sample_password host = localhost

[client] user = sample_user password = sample_password host = localhost

然后,我执行了以下命令,该命令成功执行:

Then, I executed the command below and it went successfully:

/usr/bin/mysqldump sample_table > home/username/backup_db/$(date +%F)_full.sql

但是,当我在crontabs中输入它时,它不起作用:

But, when I entered it in crontabs, it didn't worked:

0 0 * * * /usr/bin/mysqldump sample_table > /home/username/backup_db/$(date +%F)_full.sql

我什至尝试更改分钟和小时部分,但仍然无法正常工作.

I even tried changing the minutes and hour portion but still, it won't work.

推荐答案

您需要对百分号(%)进行转义,因为它在crontab条目中具有特殊含义,请改用\%.

You need to escape the percent sign (%), as it has a special meaning in crontab entries, use \% instead.

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

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