#!/usr/bin/env ruby DIR = '/nwp/m0' PATTERN = 'jmagc??.tar' files = Dir.glob(File.join(DIR, PATTERN)) # ファイルが存在しない場合 if files.empty? warn "files #{PATTERN} not found in #{DIR} - retrying" sleep 1 files = Dir.glob(File.join(DIR, PATTERN)) end if files.empty? warn "still not found - is wismon down?" puts "535" exit 0 end # 最新のmtimeを取得 latest = files.map { |f| File.mtime(f).utc }.max now = Time.now.utc diff = now - latest # 出力 printf "%6.3f\n", diff