Summary::add date to the tail -f o/p of a command

From: SURI, SONIA (SONIA) <strehan_at_lucent.com>
Date: Tue Jan 10 2006 - 06:59:40 EST
All,

Thanks to all who replied:

Basically most of them told to use "sudo" instead of tail -f .sh_history

Second option given was to use 
d=`date`
tail .sh_history | sed "s/^/$d" >> anotherfile

or

tail -f .sh_history | sed "s/^/`date `/" > output_file


Third option was to use:
tail -f .sh_history | while read Line
do echo "$( date +%Y%m%d.%T ) $Line" >> date.command.log
done


or

tail -f ~root/.sh_history |
	while read CMD; do
		date '+%Y%m%d%H%M%S'
		echo "$CMD"
	done


Fourth option was to 
turn on System Accounting, which i am not interested to do, because of the
disk limitations.

I still have to try all the above.

regards
Sonia.



-----Original Message-----
From: sunmanagers-bounces@sunmanagers.org
[mailto:sunmanagers-bounces@sunmanagers.org]On Behalf Of SURI, SONIA
(SONIA)
Sent: Monday, January 09, 2006 5:49 PM
To: sunmanagers@sunmanagers.org
Subject: add date to the tail -f o/p of a command


Hi Admins

I am trying to record the commands run by root user, as this login has to be
given at time to many different people, to run different utilities, 

My plan is to run the tail -f on .sh_history and store in another file. But
I need to put date as well in the o/p file, 

basic idea is to record the commands run by root users along with time when
it was run.

So could you share with me any idea if you have how this can be done in
better way.

regards
Sonia.
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Tue Jan 10 07:00:22 2006

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:54 EST