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.

  1. measured value of temperature. can done command sensors >> temperature.txt
  2. the time @ temperature has measured. can done date >> temperature.txt
  3. 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 * * * * *, crontab runs every minute, day, time.
  • with 2>/dev/null avoid hypothetical error messages appear in console. "targeted" /dev/null not appear. idea: ls -l /hellooooo , error message. ls -l /helloooo 2>/dev/null , not.

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -