mysqldump 在 cron 中不起作用

mysqldump is not working in cron(mysqldump 在 cron 中不起作用)

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

问题描述

首先,我在/home/username/ 中创建了 .my.cnf 并使用以下文本:

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

<代码>[客户]用户 = 样本用户密码 = 样本密码主机 = 本地主机

然后,我执行了下面的命令,它成功了:

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 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:mysqldump 在 cron 中不起作用

基础教程推荐