mysqldump is not working in 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 中不起作用


基础教程推荐
- SQL Server 2016更改对象所有者 2022-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01