Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I created a new task in crontab as shown below :

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

I'm getting following error :

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

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

like image 758
Vicky Avatar asked Feb 15 '17 05:02

Vicky


1 Answers

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')
like image 86
Inian Avatar answered Oct 26 '22 09:10

Inian