Skip to main content
Tweeted twitter.com/ServerFault/status/902695230314598402
added 8 characters in body; edited title
Source Link
peterh
  • 5k
  • 13
  • 34
  • 47

Adding How to add a timestamp to bash script log?

I have a constantly running script that I output to a log file:

script.sh >> /var/log/logfile

script.sh >> /var/log/logfile 

I'd like to add a timestamp before each line that is appended to the log. Like:

Sat Sep 10 21:33:06 UTC 2011 The server has booted up. Hmmph.

Sat Sep 10 21:33:06 UTC 2011 The server has booted up. Hmmph. 

Is there any jujitsu I can use?

Adding a timestamp to bash script log

I have a constantly running script that I output to a log file:

script.sh >> /var/log/logfile

I'd like to add a timestamp before each line that is appended to the log. Like:

Sat Sep 10 21:33:06 UTC 2011 The server has booted up. Hmmph.

Is there any jujitsu I can use?

How to add a timestamp to bash script log?

I have a constantly running script that I output to a log file:

script.sh >> /var/log/logfile 

I'd like to add a timestamp before each line that is appended to the log. Like:

Sat Sep 10 21:33:06 UTC 2011 The server has booted up. Hmmph. 

Is there any jujitsu I can use?

Source Link
Antonius Bloch
  • 5k
  • 8
  • 31
  • 42

Adding a timestamp to bash script log

I have a constantly running script that I output to a log file:

script.sh >> /var/log/logfile

I'd like to add a timestamp before each line that is appended to the log. Like:

Sat Sep 10 21:33:06 UTC 2011 The server has booted up. Hmmph.

Is there any jujitsu I can use?