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

查看:32
本文介绍了/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 手册 页面:

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天全站免登陆