0
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 5 years have passed since last update.

bash で時刻を引数に要求するコマンドのインターバル実行

Posted at

かなり初歩。

時刻を引数に要求して、指定時刻の何等かを解析するスクリプトを一定間隔で実行したい。

ま、ヘマしてリカバーが必要になったなんかで、cron 登録するのはアレだし、日時跨いじゃうし、、、って時に。

interval.sh
#!/bin/bash
# date "+%s" -d"2016/12/08 12:00:00"
declare start=1481166000

for(( i=0 ;  i <= 24 ; i++ )){
    j=$(( $start - $i * 3600 ))
    time=$(date "+%Y%m%d%H%M" -d@$j )
    echo $time &
    sleep 1
}
  • start はエポック秒。
  • 例は GNU coreutils の date
0
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
0
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?