LoginSignup
28
16

More than 5 years have passed since last update.

crontabでdateコマンドを使う時の注意点

Posted at

crontabで出力ファイル名に日付を使いたい時などにdateコマンドが使える。

注意点として、日付フォーマットを使う場合は%をエスケープする必要がある

crontab
4 0 * * * /foo/bar/hoge > hoge-$( date '+\%Y\%m\%d' ).log

エスケープしないとunexpected EOFとシンタックスエラーが出てしまう

28
16
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
28
16