しるてく

技術的な話をします

crontabでdateを扱うときとかに注意すること

45  9 * * 3 hoge.pl `date -v+2d +"%Y%m%d"`

こんな感じのことやろうとしたら

/bin/sh: -c: line 0: unexpected EOF while looking for matching ``'
/bin/sh: -c: line 1: syntax error: unexpected end of file

こけてなんだろなーと思ったらcrontabでは % 以降を標準入力として扱うらしくエスケープが必要らしい。

みんながハマった道だと思いつつメモ残しておく。