UNIXのコマンドやシェルを、指定された日付時刻や時間間隔で実行するソフト(デーモン)。
cronへのコマンドの登録(cronの設定)は、crontabというコマンドで行う。
$ crontab -e
オプション | 説明 | 備考 |
---|---|---|
-e | cron用の設定ファイルを編集する(ログインしているユーザー用の設定ファイルがviで開く) | cronにはユーザー毎にスケジュールを登録する。 |
-l | 現在の設定の内容を表示する(ログインしているユーザー用の設定) | |
-r | 設定を破棄する(ログインしているユーザー用の全設定が対象) |
「#
」で始めると、コメント行になる。
「MAILTO=メールアドレス
」という行を入れることにより、cronが実行された時に、その内容がメールで送られてくる。
このメール送信を無くすには、「MAILTO=''
」としておく。
MAILTOの行自体が無いと、crontabの設定対象であるユーザーの所へ送ってくることになる。
スケジュールは、分・時・日・月・週・コマンド、の順で1行に記述する。
#min hour day month week command * * * * * date >> /home/hishidama/cron_test
#min hour day month week command 0 2 * * * /home/hishidama/sync.sh
#min hour day month week command 0 9-17 * * * 〜
#min hour day month week command 0 9,10,11 * * * 〜
#min hour day month week command 0-59/15 * * * * 〜
#min hour day month week command 0 0-6,19-23 * * * 〜
MAILTO= * * * * * date >> /home/hishidama/cron_test
"crontab.11042" 2L, 35C written
crontab: installing new crontab
"/tmp/crontab.11042":0: bad minute
errors in crontab file, can't install.
Do you want to retry the same edit?
↓正
MAILTO='' * * * * * date >> /home/hishidama/cron_test