/bin/sh:1:语法错误:反引号中的EOF [英] /bin/sh: 1: Syntax error: EOF in backquote substitution

查看:1562
本文介绍了/bin/sh:1:语法错误:反引号中的EOF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I created a new task in crontab as shown below :

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

我遇到以下错误:

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

请帮助,我没有任何提示.

Please help, I don't have any clue whats wrong.

推荐答案

问题是cron%视为换行符.在crontab POSIX man页面上:

The problem is that cron treats % as newlines. From crontab POSIX man page:

命令中的百分号(%),除非使用反斜杠\进行转义, 将被更改为换行符,并且第一个%之后的所有数据将为 发送到命令作为标准输入.

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.

还使用命令替换语法作为$(),在旧版``语法为

Also use Command Substitution syntax as $() over the legacy `` syntax as

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

You could change your command to something like,

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

这篇关于/bin/sh:1:语法错误:反引号中的EOF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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