0

Is there an option that allows me to print a time stamp for the system time of each run of netstat? Done some looking on the man page, but nothing seems to do the trick.

For instance, if I start a run of netstat -vI 10 at 9:30:00, I'd want:

<9:30:00> [INSERT_DATA_HERE] <9:30:10> [INSERT_DATA_HERE]

etc.

Or is it better if I just write a script to run a 'date' command and pipe the catted output to a text file?

Rome_Leader
  • 2,518
  • 9
  • 42
  • 73

1 Answers1

1

If you are running the current Solaris version (Solaris 11.*), you can use the -T u or -T d option to get a timestamp for each statistic line.

Otherwise, with Solaris 10 and older, there is no builtin option but you can put the start timestamp and the interval in the netstat output filename that way:

netstat -v -I interface 10 > netstat-vI-10s-$(date +%FT%T).out
jlliagre
  • 29,783
  • 6
  • 61
  • 72