1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

任意の時間内に任意の間隔でシェルスクリプトを実行する変なやつのメモ

Last updated at Posted at 2021-08-15

#概要
引数で設定した期間内で、任意の間隔でスクリプトを実行する。

引数:command::term(s),interval(s),script

#!/bin/bash
round=$(($1/$2))
scr=$3
for ((i=0;i<$round;i++))
do
 eval ${scr}
 sleep $2
done

#使用例

$ ./pulse 60 5 "bash ./temp" #60秒間に5秒間隔でtempと言うシェルスクリプトを実行する
56478
55991
56478
55991
55991
57452
55991
56478
56965
55504
56965
56965

※変更:普通に割り算することにしました。
#補足
一分毎とかなら普通にcron使ったほうが良いよ。

おわり。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?