I'm attempting to watch my network statistics via putty and want to write the statistics to a log file every one second. I've configured putty to log he ssh session to a log file. However, I'm struggling to issue a putty command that repeated issues the command to pull the statistics.

My first approach was to use the "watch" command. This worked well to execute the command every second, however, it would overwrite the terminal output every time it updated and the log file would not show the history.

My question: How do I configure the watch command to append the session output instead of just repeatedly overwrite lines?

  • Can you clarify what you mean by "watch my network statistics via putty"? Are you trying to watch this on a linux server (which is connected via SSH using Putty ) or is it something else?
    – sla3k
    Commented Nov 5, 2018 at 18:23
  • I'm attempting to log a file from a windows machine that is SSH'd into a Linux machine. I've got putty logging all outputs from the SSH session to a local file, I'm just struggling to find an SSH command that can repeatedly request the network stats.
    – Izzo
    Commented Nov 5, 2018 at 18:58

2 Answers 2


The watch utility uses curses to initialize and refresh the screen, so I think you're swimming upstream in trying to make it append instead of overwrite. I would suggest, instead, an infinite shell-loop:

while :
  ss -s     ## for example
  sleep 60  ## for example

This would output the statistics you want at the interval you want, in a scrolling/appending fashion, and also interruptible with Control-C, like watch is.

It does not provide any of watch's features, like highlighting differences, providing a command title, or exiting on various conditions. You work around some of these by manually emitting the test command and/or adding a test on the command's return code to break out of the loop.


Why not use a simple shell script to run the command over and over and write the output to a file. Something like this:

#!/usr/bin/env bash
while true;
 free >> file.txt
 sleep 2

free is a command that outputs the free RAM on the linux system. Change that with your command to run. >> will append the output to file.txt. You can change the sleep option to n number of seconds per your need.

NOTE: This script will run indefinitely and you'd need to stop it (CTRL + C) once you have enough logs.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .