すずけんメモ

技術メモです

crontabの%は終端文字

はまった。

* * * * * wc -l `date --date "1 days ago" +%Y%m%d`.log >> logcount.log
/bin/sh: -c: line 0: unexpected EOF while looking for matching ``'
/bin/sh: -c: line 1: syntax error: unexpected end of file

crontabだと%はコマンドの終わりと解釈されてしまう。以下のようにする。

* * * * * wc -l `date --date "1 days ago" +\%Y\%m\%d`.log >> logcount.log

参考: dateコマンド と crontab の コマンドライン中の %(パーセント)記号 - keigoiの日記 http://d.hatena.ne.jp/keigoi/20090204/1233715870