mysqldump在cron中不起作用 [英] mysqldump is not working in 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屋!