LoginSignup
1
3

More than 5 years have passed since last update.

crontabに関して

Posted at

環境

Ubuntu 14.04

crontab

設定した時間にコマンドを実行してくれる!!!!
なにこれ便利!!

オプション

オプション
-u [ユーザ名] 指定したユーザのファイルを操作できる
-r ファイルの削除
-e ファイルの編集
-l ファイルを標準出力

特に削除コマンドは要注意!!
削除しますか?と言った警告も出ずに実行すると全て削除されます。
キーボードでeとrが横にあるのは陰謀...

書き方

edit
* * * * * [実行コマンド]

設定の項目は左から分、時、日、月、曜日となっている。
いくつか例を挙げる。

example
0,10,20,30,40,50 * * * * ruby hello.rb
*/10  *  *  *  * ruby hello.rb

上と下は同じ動作をする。
毎時10分おきにhello.rbが自動的に実行される。

example
0 0 1 1 * new_year.rb

と記述すると1月1日に実行される。

1
3
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
1
3