LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   using watch to make a log? (https://www.linuxquestions.org/questions/linux-general-1/using-watch-to-make-a-log-385379/)

slinky2004 11-21-2005 11:36 PM

using watch to make a log?
 
is it possible to make watch r edirect it's output into a file to make a kind of makeshift log? so if i wanted to log my cpu temperature i'd do this:
Code:

watch -n.5 cat /proc/acpi/thermal_zone/ATF0/temperature
only somehow get it to save each output to a file so it would look something like this:
Code:

temperature:            53 C
temperature:            53 C
temperature:            53 C
temperature:            53 C
temperature:            51 C
temperature:            54 C
temperature:            53 C
temperature:            53 C
temperature:            57 C
temperature:            55 C
temperature:            55 C

if i could get it to only save the output when the number changes it would be even better.

ahedler 11-21-2005 11:50 PM

After taking a really quick look at the watch man page, I'd think you could just tack on ">> somelog.file" to the end of your command to redirect the output to the file.

Then again, rather than using watch, which I suspect you're running from a command line, possibly in the background, why not try running the cat statement with the redirect in a cron job? Make sure you use ">>" and not ">" so you will be appending to the log file, rather than overwriting it each time it executes.

-Alan

slinky2004 11-22-2005 12:37 PM

appending >> on watch didnt work, but i'll try the cron thing. thx


All times are GMT -5. The time now is 03:35 AM.