#!/bin/bash
#
# Linux Puppy 6.3.0 SiegeWorks 2016 A.P.K.
#
# Send CPU temps to file every 15 minutes
# NOTE: This messes with icon for CPUtemp
count=1
done=0
while [ $count -le 10 ]
do
sleep 1
(( count++ ))
if [ $count == 5 ]
then
continue
fi
date "+ %m/%d/%y %r" >> ~/Documents/CPU_TEMPS.txt
sensors -f >> ~/Documents/CPU_TEMPS.txt
sleep 900
done
Script sends CPU temps to file
Script sends CPU temps to file
This works but distorts CPUtemps icon a bit.
Thanks,
Andy
Slacko 6.3.0 FULL INSTALL
JWM
File Manager - Thunar
Andy
Slacko 6.3.0 FULL INSTALL
JWM
File Manager - Thunar
I wrote it.ebisu wrote:done=0 looks wrong. And why does it avoid writing when count=5? Who wrote this?
Interested in any suggestions you have.
Newer version.
#!/bin/bash
#
# Linux Puppy 6.3.0 SiegeWorks 2016 A.P.K.
#
# Send CPU temps to file every 15 minutes
# NOTE: This messes with icon for CPUtemp
count=1
done=0
while [ $count -le 10 ]
do
sleep 1
(( count++ ))
if [ $count == 5 ]
then
continue
fi
date "+ %m/%d/%y %r" >> ~/Documents/CPU_TEMPS.txt
sensors -f >> ~/Documents/CPU_TEMPS.txt
sleep 900
done
#!/bin/bash
#
# Linux Puppy 6.3.0 SiegeWorks 2016 A.P.K.
#
# Send battery state to file every 15 minutes
# Useful in determining how long your battery will actually last
#
count=1
done=0
echo Laptop Battery Status Report >> Battery_State.txt
while [ $count -le 10 ]
do
sleep 1
(( count++ ))
date "+ %m/%d/%y %r" >> Battery_State.txt
grep remaining /proc/acpi/battery/*/state >> Battery_State.txt
#
grep full /proc/acpi/battery/*/info >> Battery_State.txt
#
grep charging /proc/acpi/battery/*/state >> Battery_State.txt
sleep 900
done
Thanks,
Andy
Slacko 6.3.0 FULL INSTALL
JWM
File Manager - Thunar
Andy
Slacko 6.3.0 FULL INSTALL
JWM
File Manager - Thunar
I have answered all questions that I am aware of.Flash wrote:I suggest that you try a dialog, where you answer questions that other people ask, and maybe explain what you're doing in the script. Terse and cryptic just doesn't cut it.
My scripts also have notes that explain what the script does.
# Send battery state to file every 15 minutes
# Useful in determining how long your battery will actually last
Thanks,
Andy
Slacko 6.3.0 FULL INSTALL
JWM
File Manager - Thunar
Andy
Slacko 6.3.0 FULL INSTALL
JWM
File Manager - Thunar
Flash,
This corrects that.
The 'grep design line' does not print
design capacity: 7800 Mah
that I would like.
This corrects that.
The 'grep design line' does not print
design capacity: 7800 Mah
that I would like.
count=1
done=0
while [ $count -le 10 ]
do
(( count++ ))
date "+ %m/%d/%y %r" >> Battery_State.txt
grep remaining /proc/acpi/battery/*/state >> Battery_State.txt
grep full /proc/acpi/battery/*/info >> Battery_State.txt
grep charging /proc/acpi/battery/*/state >> Battery_State.txt
grep design /proc/acpi/battery/*/capacity >> Battery_State.txt
sleep 300 # Update file every 5 minutes
done
Thanks,
Andy
Slacko 6.3.0 FULL INSTALL
JWM
File Manager - Thunar
Andy
Slacko 6.3.0 FULL INSTALL
JWM
File Manager - Thunar
I suggest that people drop the while test SOMETHING syntax .
Reason :
The loop needs to go until the end to be tested again.
Usually there are tests possible to break the loop before reaching the end.
Just
while true; do code; test || break; code; test || break; code; done
is simpler :
Sophitist: Your count code actually works five times, then would skip 5 times and then finish.
So no need for the last five counts.
And done=0 is an unused variable.
Reason :
The loop needs to go until the end to be tested again.
Usually there are tests possible to break the loop before reaching the end.
Just
while true; do code; test || break; code; test || break; code; done
is simpler :
Code: Select all
_exit(){ echo "$*"; test -s /tmp/dir/your_file; exit $?; } #returns 0 if file has content
mkdir -p /tmp/dir || _exit "Unable to create /tmp/dir"
touch /tmp/dir/your_file || _exit "Unable to open /tmp/dir/your_file"
trap "_exit 'Caught Signal'" INT TERM KILL
while :;
do
test -d /proc/acpi/battery || { echo "/proc/acpi/battery missing'; break; }
grep -H '.' /proc/acpi/battery/*/state >>/tmp/dir/your_file || { echo "No state file"; break; }
sleep 300 # Update file every 5 minutes
done
test -s /tmp/dir/your_file #returns 0 if file has content
So no need for the last five counts.
And done=0 is an unused variable.
Could/would a cron job best achieve your resultant "log"? If a cron scipt, it only need be a couple lines and no testing/looping required.
So that it reflects a historical logging, would it be best to name your_fileHope this is helpful
So that it reflects a historical logging, would it be best to name your_file
Code: Select all
scriptname-or-purpose.log
Last edited by gcmartin on Fri 15 Jan 2016, 06:53, edited 1 time in total.
Interesting idea. I have never known what my cpu temps are and it would be good to know. Unfortunately the script output seems to be missing the critical info on my system (Slacko 5.6 derivative). Maybe I lack the sensors software or interface?
Also - if you want to extend the script a little it could probably do with some method of checking whether or not the directory exists (which it didn't on my system so the script initially could not run correctly)
Also - if you want to extend the script a little it could probably do with some method of checking whether or not the directory exists (which it didn't on my system so the script initially could not run correctly)
- Attachments
-
- output.jpg
- (16.75 KiB) Downloaded 246 times
Hello scientist.
If ever you get tired of scripting , there's this ready-made, icon tray thingy called
gatotray. Exists in 32-bit and 64-bit.
BFN.
If ever you get tired of scripting , there's this ready-made, icon tray thingy called
gatotray. Exists in 32-bit and 64-bit.
BFN.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
Hello Semme.
with the acpi utility.
BFN.
Not necessarily. You can get some CPU temperature infoSemme wrote:You need lm_sensors, then run: sensors-detect to see whether you have any available kernel modules to load.
with the acpi utility.
BFN.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
You need to load the temperature kernel driver manually, since its modalias
is not recognized by the puppy boot scripts .
For intel P4 it was it87 and now it should be coretemp .
The temperature driver creates files in sysfs :
is not recognized by the puppy boot scripts .
For intel P4 it was it87 and now it should be coretemp .
The temperature driver creates files in sysfs :
Code: Select all
#!/bin/ash
TEMP_FILES=`find /sys -type f -name "temp*_input"`
TEMP_FILES=`echo "$TEMP_FILES" | sed '/^$/d'`
test "$TEMP_FILES" || { echo "No temparature files found."; exit 1; }
while :;
do
while :;
do
read -r tf;
#echo tf=$tf
test "$tf" || break 1; #newline
test -f "$tf" || break 2; #exit program
echo -n $tf:;
cat $tf;
echo;
sleep 2;
done <<EoI
$TEMP_FILES
EoI
sleep 2
done
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal :P
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal :P
CPU temperature tray option
Gotta hand it to @Musher0 on this one. Although it does not produce a running logfile, it is useful and easily spotted.
Anyone else tried it?
The primary difference between what he has presented and the thread is his is constantly visible while this thread does not discuss temperature visibility.
I imagine, that if desired, his utility could provide a log as an option.
Nice!
Anyone else tried it?
The primary difference between what he has presented and the thread is his is constantly visible while this thread does not discuss temperature visibility.
I imagine, that if desired, his utility could provide a log as an option.
Nice!