Hi: I created, as root, a file with 'crontab -e', whose contents is:
Code:
* * * * * /almacen/work/batt_low/bl02.sh
where bl02.sh is
Code:
bill@server:/almacen/work/batt_low$ cat bl02.sh
#!/bin/bash
## FILE NAME: bl.sh
## PROG APPL: query the battery charge level. Audibly alert users
## when level is bellow THRESHOLD.
## Instructions: in a root console, do 'crontab -e', which will open
## /var/spool/cron/crontabs/root, ready to edit. In the bottom line
## you will read some fancy file name. It does not matter. The
## file you are editing is that mentioned above. Type
## '* * * * * <this script complete file name>', without the quotes.
## Close the file. Now the script will be run every minute.
THRESHOLD=1200
a1=$(grep remaining /proc/acpi/battery/BAT0/state)
current_level=$(echo $a1 | grep -o '[0-9]\+')
if [ $current_level -gt THRESHOLD ]
then
exit 0 #Battery level OK
fi
## Battery is low here
# notify-send "****** Battery low *******" "*********************"
## We assume we are running as root (alsactl).
alsactl store
## The following commands taken from man amixer, EXAMPLES.
amixer -c 0 sset Master playback 100 unmute
amixer -c 0 sset PCM 100
amixer -c 0 sset Headphone 100% unmute
amixer -c 0 sset Speaker 100% unmute
aplay /usr/share/orage/sounds/Phone.wav
alsactl restore
exit 1
With THRESHOLD= 7000 the audio file began to play every minute. Then I change it to THRESHOLD= 1200. And now the file plays though the battery is at 2200 mA. The script is not faulty. How can I tell cron that the file is a new one?