> ## Content Index
> Fetch the complete content index at: https://www.bagz.fr/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to capture results of a watch in a file
- URL: https://www.bagz.fr/how-to-capture-results-of-a-watch-in-a-file/
- Published: 2015-02-19T09:47:18.000Z
- Updated: 2015-02-19T09:47:18.000Z
- Author: bgazui
- Tags: Linux, #Migrated-1790668826633, #wp, #wp-post, #Import 2026-09-29 08:00

For debugging purposes, it can sometimes be useful to write the results of a command executed at a given time lapse. You can easily monitor a command by using the **watch** command.

By default a **watch** command is only displaying result, and you have to be in front of to see the results. If you want to write them in a file with a timestamp, you can easily do it by using this command that combines a **watch** command with **tee**:

\# watch -t -n 1 "(date '+TIME:%H:%M:%S' ; netstat -np | egrep -i \*:443) | tee -a /tmp/logfilewatch"

You can now open your file **/tmp/logfilewatch** and see the results you just got!  
For example, here is what you could get with my previous command, checking all the connections on port TCP 443:

TIME:22:24:22  
tcp 0 0 0.0.0.0:443 0.0.0.0:\* LISTEN 1722/apache2  
TIME:22:24:23  
tcp 0 0 0.0.0.0:443 0.0.0.0:\* LISTEN 1722/apache2  
TIME:22:24:35  
tcp 0 0 192.168.100.250:443 12.34.56.78:27911 TIME\_WAIT -  
TIME:22:24:36  
tcp 0 0 192.168.100.250:443 12.34.56.78:27911 TIME\_WAIT -  
TIME:22:24:37  
tcp 0 0 192.168.100.250:443 12.34.56.78:27911 TIME\_WAIT -  
TIME:22:24:38  
tcp 0 0 192.168.100.250:443 12.34.56.78:27911 TIME\_WAIT -  
TIME:22:24:39  
tcp 0 0 192.168.100.250:443 12.34.56.78:27916 SYN\_RECV -  
tcp 0 0 192.168.100.250:443 12.34.56.78:27911 TIME\_WAIT -  
TIME:22:24:41  
tcp 0 0 192.168.100.250:443 12.34.56.78:27916 ESTABLISHED 16810/apache2  
tcp 0 0 192.168.100.250:443 12.34.56.78:27911 TIME\_WAIT -  
TIME:22:24:42  
tcp 0 0 192.168.100.250:443 12.34.56.78:27916 ESTABLISHED 16810/apache2  
tcp 0 0 192.168.100.250:443 12.34.56.78:27911 TIME\_WAIT -