Jun 28

How to append a date time stamp to a logfile

Category: Linux,webserver   — Published by goeszen on June 28, 2016 at 2:35 pm

Here's a handy CLI one-liner to add a date timestamp to a file, in case you want to mark a certain position/date/time in a log-file, for example in case you are doing changes to a web-site or want to separate events on an Apache instance, events which are before and after a certain time:

echo "----- `date -u` -----" >> logs/access.log

This will print the current UTC time, enclosed by a number of dashes, and write it in append mode into the logfile access.log.

Leave a Reply

=