1
2

More than 1 year has passed since last update.

Raspberry Pi で cron を使用して繰り返し処理を行う

Posted at

Raspberry Pi を利用して繰り返し処理を行いたい

1. 環境

ソフト・ハード バージョン
Raspberry Pi Raspberry Pi 3 Model B+
Raspbian 10.11
Kernel 5.10
Python 3.7.3

2. コマンド

コマンド 内容
sudo apt-get install chkconfig チェック用モジュールインストール?
chkconfig cron cronが動作確認
systemctl enable cron cron off のとき、ON にする
sudo /etc/init.d/cron start cronの起動
sudo service cron restart cronサービスの再起動
sudo /etc/init.d/cron stop cronの停止
sudo crontab -e エディタ立ち上げ
Ctrl + O エディタ書き込み
Ctrl + X エディタ終了
crontab -l 設定されてるcronを表示する
crontab -r cronは削除する

3. crontab 内容

基本

crontab
*  *  *  *  * command
    曜日
範囲 0-59 0-23 1-31 1-12 0-7(0と7はSunday)

コマンド

コマンド 内容
[*] 毎時
[ , ] and
[ / ] ステップ数
[ - ] 範囲指定

記述 実行内容
* * * * * 1分毎に実行
32 02 * * * 02:32に実行
*/10 * * * * 10分毎に実行
0 */4 * * * 4時間毎に実行
0-10 20 * * * 20:00から20:10まで 1分毎に実行
0,30 20 * * 2,4 毎週,火,木曜の 20:00と 20:30に実行
* 20 * * * 20:00から 20:59まで 1分おきに実行
0 1 * * * 1:00に実行
0 * * * * 毎時 0分に 1時間おきに実行
2 8-20/3 * * * 8:02,11:02,14:02,17:02,20:02に実行
10 3 1 * * 毎月1日の 3:10分 に実行
0 12 * * 0 毎週日曜日 12:00 に実行

参考にさせて頂いたサイト

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