linux - How to store the temperature and corresponding time to a file through Shell? -
my laptop getting heated high temperatures around 60-75 degree celsius. have installed lm_sensors. , have found out few command that.i need generate file following parameters measured @ every 1 minutes.
- measured value of temperature. can done command
sensors >> temperature.txt - the time @ temperature has measured. can done
date >> temperature.txt - the number of running processes
ps-aux(but won't give number of processes).
i came know task done shell scripts(is ?). can suggest me way have little idea shell scripting?
the script like:
#!/bin/bash file=/your_home_dir/temp_info temperature=$(sensors | tail -3) when=$(date "+%y%m%d_%h%m%s") working_proc=$(ps -aux | wc -l) echo "$when num_proc: $working_proc" >> $file echo "$temperature" >> $file with output like
20130724_131150 num_proc: xxx temp line1 temp line2 20130724_131250 num_proc: yyy temp line1 temp line2 ... to have calculated every 1 minute, can use crontab:
do crontab -e , add following line:
* * * * * /bin/sh /path/to/script.sh 2>/dev/null you can see more information crontab in https://stackoverflow.com/tags/crontab/info. basic ideas:
- with expression
* * * * *,crontabruns every minute, day, time. - with
2>/dev/nullavoid hypothetical error messages appear in console. "targeted"/dev/nullnot appear. idea:ls -l /hellooooo, error message.ls -l /helloooo 2>/dev/null, not.
Comments
Post a Comment