2006年05月08日

シェルスクリプトでタイムスタンプの比較

livedoorClipに登録 | このエントリーをはてなブックマークに追加 | del.icio.usに登録 | MM/Memoに登録

tinydnsのdataファイルとdata.cdbファイルの比較

dataとdata.cdbがほぼ同時刻に生成された事を確認したい。

$ man sh

file1 -nt file2
True if file1 is newer (according to modification date) than
file2, or if file1 exists and file2 does not.
file1 -ot file2
True if file1 is older than file2, or if file2 exists and file1
does not.


-nt でも -ot でも同時刻の場合にfalseを返して来る。
同時刻である場合の比較演算子が無いではないか!
そもそもそんな比較をするヤツは居ないく需要は低いのだろう。

秒単位ではなく分単位での比較をしている模様。
やりたい事を満たせるので結局こうした。


#!/bin/sh

is_same_mtime() {
[ $# = 2 ] || return 1
(! [ $1 -nt $2 ] && ! [ $1 -ot $2 ])
return $?
}


cronで実行しているからtinydns-dataの実行終了に60秒もかかる事
はないはずだ!サーバが高負荷の時は発生してしまうかも知れない。


半袖 at 15:40│Comments(0)TrackBack(0)ほげり道 

トラックバックURL

この記事にコメントする

名前:
URL:
  情報を記憶: 評価: 顔