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.

実行時刻を記録してログを残したい。

0
Posted at

cronで定刻実行するスクリプトで実行時刻も記録したい

{ echo =====`date`=====; スクリプト; } >> ログファイル

以下解説

{ ●●●; ▲▲▲; }

括弧でとスペースで括られ、セミコロンで区切られたコマンドの出力を一つにまとめる

echo =====`date`=====

現在時刻を「=」で囲んで表示。
例:=====2020年 8月 19日 水曜日 15:22:14 JST=====

>>

出力を追加していくリダイレクト

ログの出力イメージ

=====2020年 8月 19日 水曜日 15:59:01 JST=====
(スクリプトの出力結果がここに入る)
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?