gpt4 book ai didi

bash -/bin/sh : 1: Syntax error: EOF in backquote substitution

转载 作者:行者123 更新时间:2023-11-29 08:49:21 29 4
gpt4 key购买 nike

我在 crontab 中创建了一个新任务,如下所示:

*/2 * * * *       mongodump --db prodys --out /backup/databases/mongoDatabases/`date +"%m-%d-%y"`

我收到以下错误:

/bin/sh: 1: Syntax error: EOF in backquote substitution

请帮忙,我不知道哪里出了问题。

最佳答案

问题是 cron% 视为换行符。来自 crontab POSIX man 页面:

Percent-signs (%) in the command, unless escaped with backslash \, will be changed into newline characters, and all data after the first % will be sent to the command as standard input.

也可以使用 Command Substitution语法为 $() 而不是遗留的 `` 语法为

您可以将命令更改为类似的内容

*/2 * * * *       mongodump --db prodys --out /backup/databases/mongoDatabases/$(date +'\%m-\%d-\%y')

关于bash -/bin/sh : 1: Syntax error: EOF in backquote substitution,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42241371/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com