I need to write script or command line code in Ubuntu which take CPU temperature and % of CPU usage from lm_sensors or something similar. This information I would like to save to .txt file with date and time of each measurement. I tried to write .sh file which is below. But it doesn't work as I would like to. Can somebody help me?
while true; do echo $( date '+%H:%M:%S' ): $( sensors | grep 'CPU Temperature' | sed -r 's/^.*: +(.*) +[(].*$/\1/' ) >> temperature.txt; echo $( date '+%H:%M:%S' ): $( top -b -n 1 | grep 'CPU:') >> cpu.txt; sleep 1; done