Battery Empty -> force shutdown

hi

Howto force shutdown on the notebook with freeBSD before battery is empty?

Try 'shutdown now' or '/sbin/init 0'

I mean to shutdown automaticaly from script, cron etc.

#!/bin/csh
# /usr/local/sbin/batterytest
# Baterry control
 
set restminutes=`/sbin/sysctl -n hw.acpi.battery.time`
set modus=`/sbin/sysctl -n hw.acpi.battery.state`
 
# does it have Power Supply connected?
if ( "${modus}" == "1" ) then
 
  # 7 Minutes?
  if ( "${restminutes}" < "7" ) then
    shutdown -p +2 "The Battery is empty! The Computer will shutdown after 2 Minutes!" &
  endif

endif
# chown root /usr/local/sbin/batterytest
# chmod u+x /usr/local/sbin/batterytest

add to crontab:

*/5 * * * * /usr/local/sbin/batterytest