HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

i want to print one log file with time and date

 
rajesh73
Super Advisor

i want to print one log file with time and date

i want to print one log file with time and date vmstat > /home/raj/ file name with time and date .txt
4 REPLIES
Pete Randall
Outstanding Contributor

Re: i want to print one log file with time and date

Is there anything wrong with the simple method of

 

date > /home/raj/ file

vmstat >> /home/raj/ file


Pete
Pete Randall
Outstanding Contributor

Re: i want to print one log file with time and date

Or do you want the date stamp in the name of the file?

 

vmstat > /home/raj/file`date`


Pete

Re: I want to print one log file with time and date

>Is there anything wrong with the simple method of

 

Or even: { date; vmstat; } > /home/raj/ file

 

>Or do you want the date stamp in the name of the file?

 

And: vmstat > /home/raj/file$(date)

James R. Ferguson
Acclaimed Contributor

Re: I want to print one log file with time and date

Hi:

 

And if you want to tag every line with a date stamp, you could do:

 

vmstat | while read LINE
do
    echo "$(date '+%m/%d/%Y') ${LINE}"
done 

 ...which written on a command line is:

 

vmstat|while read LINE; do echo "$(date '+%m/%d/%Y') ${LINE}"; done 

Regards!

 

...JRF...