0

I have the following crontab:

# m h  dom mon dow   command
* *   * * *   /bin/date                >> /tmp/date.log  2>&1
* *   * * *   /bin/date "+%F_%H-%M-%S" >> /tmp/date2.log 2>&1

The first one executes correctly .. writing the current date to /tmp/date.log The second one doesn't work. /tmp/date2.log is never created. The only difference is that the second date command has a formatting string as parameter. Outside of the cronjob the second date command (/bin/date "+%F_%H-%M-%S") works fine.

What could be the reason for this behavior?

My system:

uname -a

Linux corsair 4.15.0-50-generic #54-Ubuntu SMP Mon May 6 18:46:08 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

lsb_release -a

Distributor ID: LinuxMint
Description:    Linux Mint 19.1 Tessa
Release:    19.1
Codename:   tessa
qwertz
  • 121
  • 4

1 Answers1

2

Unescaped percent signs in the command are replaced by newlines, see crontab(5). You need to put a backslash in front of them.

Simon Richter
  • 3,209
  • 17
  • 17