障害機器のLOGの取得のため長期にLOGを取得する必要があるのですが、自動で日付ごとにLOGファイルを更新してくれる方法等がありますでしょうか。
Tera Termマクロで、logcloseとlogopenを繰り返せばOKだと思います。
こんな感じでしょうか。
;; ログの置き場所 strLogPath = 'C:\LOG\' ;; ログファイル名の先頭につける文字列 strPrefix = 'teraterm-' ;; ログファイルの拡張子 strExtension = '.log' ;; ログファイルオプション ;; bLogBinary (0: テキスト, 0以外: バイナリ) bLogBinary = 0 ;; bLogAppend (0: 上書き, 0以外: 追記) bLogAppend = 1 ;; 現在のログファイル名 strCurLogfile = '' ;; メインループ :mainloop ;; 日付の取得 getdate strDate strcopy strDate 1 4 strYear strcopy strDate 6 2 strMonth strcopy strDate 9 2 strDay ;; 時刻の取得 gettime strTime strcopy strTime 1 2 strHour strcopy strTime 4 2 strMinute strcopy strTime 7 2 strSecond ;; ログファイル名を生成 strLogfile = strLogPath strconcat strLogfile strPrefix strconcat strLogfile strYear strconcat strLogfile '-' strconcat strLogfile strMonth strconcat strLogfile strDay ;strconcat strLogfile '-' ;strconcat strLogfile strHour ;strconcat strLogfile strMinute ;strconcat strLogfile strSecond strconcat strLogfile strExtension ;; ログファイル名が同じなら、待ち strcompare strCurLogfile strLogfile if result = 0 goto waitandnext ;; ログを開始 logclose strCurLogfile = strLogfile logopen strCurLogfile bLogBinary bLogAppend ;; 一定時間何もしない :waitandnext pause 60 goto mainloop
最新のTeraTermをいじってみて驚いた - u-ichiのにっき
設定ファイルに以下の内容を記述すれば可能。
LogHideDialog=on LogDefaultName=teraterm%y%m%d.log LogAutoStart=on
細かい部分はお好みで修正してください。
Tera Termマクロで、logcloseとlogopenを繰り返せばOKだと思います。
こんな感じでしょうか。
;; ログの置き場所 strLogPath = 'C:\LOG\' ;; ログファイル名の先頭につける文字列 strPrefix = 'teraterm-' ;; ログファイルの拡張子 strExtension = '.log' ;; ログファイルオプション ;; bLogBinary (0: テキスト, 0以外: バイナリ) bLogBinary = 0 ;; bLogAppend (0: 上書き, 0以外: 追記) bLogAppend = 1 ;; 現在のログファイル名 strCurLogfile = '' ;; メインループ :mainloop ;; 日付の取得 getdate strDate strcopy strDate 1 4 strYear strcopy strDate 6 2 strMonth strcopy strDate 9 2 strDay ;; 時刻の取得 gettime strTime strcopy strTime 1 2 strHour strcopy strTime 4 2 strMinute strcopy strTime 7 2 strSecond ;; ログファイル名を生成 strLogfile = strLogPath strconcat strLogfile strPrefix strconcat strLogfile strYear strconcat strLogfile '-' strconcat strLogfile strMonth strconcat strLogfile strDay ;strconcat strLogfile '-' ;strconcat strLogfile strHour ;strconcat strLogfile strMinute ;strconcat strLogfile strSecond strconcat strLogfile strExtension ;; ログファイル名が同じなら、待ち strcompare strCurLogfile strLogfile if result = 0 goto waitandnext ;; ログを開始 logclose strCurLogfile = strLogfile logopen strCurLogfile bLogBinary bLogAppend ;; 一定時間何もしない :waitandnext pause 60 goto mainloop
コメント(1件)
--------------------------------------------------------
;; TeraTerm Ver 4.62 以降で利用可能(最新版を推奨)
;; ログの置き場所
strLogPath = 'C:\LOG\'
;; ログファイルオプション
;; bLogBinary (0: テキスト, 0以外: バイナリ)
bLogBinary = 0
;; bLogAppend (0: 上書き, 0以外: 追記)
bLogAppend = 1
;; 現在のログファイル名
strCurLogfile = ''
;; メインループ
:mainloop
;; ログファイル名の生成(strf)
;getdate strLogfile "teraterm-%Y-%m%d-%H%M%S.log"
getdate strLogfile "teraterm-%Y-%m%d.log"
;; ログファイル名が同じなら、待ち
strcompare strCurLogfile strLogfile
if result != 0 goto error
;; ログを開始
logclose
strCurLogfile = strLogfile
logopen strCurLogfile bLogBinary bLogAppend
if result = 0 goto waitandnext
;; 一定時間何もしない
:waitandnext
pause 60
goto mainloop
:error
messagebox 'Log open error' 'Error message'