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

前端 未结 1 1550
闹比i
闹比i 2021-01-01 16:44

I created a new task in crontab as shown below :

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


        
相关标签:
1条回答
  • 2021-01-01 17:09

    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')
    
    0 讨论(0)
提交回复
热议问题