LoginSignup
71
60

More than 5 years have passed since last update.

システム起動時に1度だけ実行されるCronを設定する

Last updated at Posted at 2017-02-18

Cronにそのような構文があらかじめ用意されている。

普段時刻を設定している箇所に@rebootを指定すれば良い。

echo '@reboot /path/to/script' | crontab

@からはじまる構文は他にも下記のようなものがある。(Ubuntu 16.04.2 LTSの"man 5 crontab"より抜粋)

              string         meaning
              ------         -------
              @reboot        Run once, at startup.
              @yearly        Run once a year, "0 0 1 1 *".
              @annually      (same as @yearly)
              @monthly       Run once a month, "0 0 1 * *".
              @weekly        Run once a week, "0 0 * * 0".
              @daily         Run once a day, "0 0 * * *".
              @midnight      (same as @daily)
              @hourly        Run once an hour, "0 * * * *".
71
60
0

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
71
60