linux - Why does bash short curcuit fail in crontab? -
if in terminal do
[ $(/usr/bin/date +"%y%m%d") -le 20171209 ] && echo aaa >> /tmp/a
it works. if in crontab -e
* * * * * echo aaa >> /tmp/a
then works. if in crontab -e
* * * * * [ $(/usr/bin/date +"%y%m%d") -le 20171209 ] && echo aaa >> /tmp/a
then nothing happens.
looking @ /var/log/cron
see
sep 12 08:36:01 enote crond[8809]: (root) cmd ([ $(/usr/bin/date +")
question
can explain issue is?
percent sign has special meaning in crontab, must escaped \%
man 5 crontab
/percent
percent-signs (%) in command, unless escaped backslash (\), changed newline characters, , data after first % sent command standard input.
Comments
Post a Comment