Chris Bognar

  • Content Count

    4
  • Joined

  • Last visited

Reputation Activity

  1. Like
    Chris Bognar got a reaction from Seneca in Script to check the power status, and shutdown if battery is low!   
    If anyone is interested, I've created a shell script that can be run with cron to check A/C and battery status, and do a graceful shutdown when a battery threshold is met.  It also logs power outages, battery drain when off A/C, and when it posts a shutdown (if any).  This is a simple script, nothing fancy, but works for me.  It has a granularity of one minute (cron is limited to one minute intervals), but I've been able to keep the system up on heavy load for 4-5 minutes before the script generates a shutdown on low battery.
     
    The script is generous -- it waits for 916mV or less before a shut-down.  This value was provided by the KOBOL team on their Wiki as the recommended shutdown threshold for the battery, but can be changed via the script.  You can comment out any file-logging lines, or change the file location, also from within the script.  I've heavily commented it, should be pretty easy to follow.
     
    Copy the script below into a file named whatever you choose, place it where you want to run it, and cron it to get it going.  It should only create disk writes when the power is out or when shutting down from battery drain on no A/C (a few lines once per minute), and will create no disk writes  if you comment out the logging.
     
     
    Let me know how it works for you, if you use it.  I've been testing it for the past couple of days, and it's worked as intended.  I'm always open to code tips, and I'm still learning, so any advice is appreciated.
  2. Like
    Chris Bognar got a reaction from gprovost in Script to check the power status, and shutdown if battery is low!   
    I haven't done much work outside of shell scripting and config files, and I'm not experienced enough to work inside the systemd framework for fear of trashing the system beyond my knowledge.  I've been reading the bash guide TRS-80 offered as a reference, and I've come away with a better understanding of some of the more complex ideas, but I've been browsing it for 3 days and still have quite a bit to read and absorb.  Many thanks for his advice and fast replies.
     
    Here is a cleaned up, easier to read version of my original script . . . I haven't modified it operationally because it works like I need it to, but hopefully my style will improve as I get more involved with it.  Also thanks to gprovost for his quick replies and exceptional help to the community as a whole.  This is truly a fantastic machine and labor of love for the KOBOL team.
     
     
     
  3. Like
    Chris Bognar got a reaction from aprayoga in Script to check the power status, and shutdown if battery is low!   
    If anyone is interested, I've created a shell script that can be run with cron to check A/C and battery status, and do a graceful shutdown when a battery threshold is met.  It also logs power outages, battery drain when off A/C, and when it posts a shutdown (if any).  This is a simple script, nothing fancy, but works for me.  It has a granularity of one minute (cron is limited to one minute intervals), but I've been able to keep the system up on heavy load for 4-5 minutes before the script generates a shutdown on low battery.
     
    The script is generous -- it waits for 916mV or less before a shut-down.  This value was provided by the KOBOL team on their Wiki as the recommended shutdown threshold for the battery, but can be changed via the script.  You can comment out any file-logging lines, or change the file location, also from within the script.  I've heavily commented it, should be pretty easy to follow.
     
    Copy the script below into a file named whatever you choose, place it where you want to run it, and cron it to get it going.  It should only create disk writes when the power is out or when shutting down from battery drain on no A/C (a few lines once per minute), and will create no disk writes  if you comment out the logging.
     
     
    Let me know how it works for you, if you use it.  I've been testing it for the past couple of days, and it's worked as intended.  I'm always open to code tips, and I'm still learning, so any advice is appreciated.
  4. Like
    Chris Bognar got a reaction from EduardCH in Script to check the power status, and shutdown if battery is low!   
    If anyone is interested, I've created a shell script that can be run with cron to check A/C and battery status, and do a graceful shutdown when a battery threshold is met.  It also logs power outages, battery drain when off A/C, and when it posts a shutdown (if any).  This is a simple script, nothing fancy, but works for me.  It has a granularity of one minute (cron is limited to one minute intervals), but I've been able to keep the system up on heavy load for 4-5 minutes before the script generates a shutdown on low battery.
     
    The script is generous -- it waits for 916mV or less before a shut-down.  This value was provided by the KOBOL team on their Wiki as the recommended shutdown threshold for the battery, but can be changed via the script.  You can comment out any file-logging lines, or change the file location, also from within the script.  I've heavily commented it, should be pretty easy to follow.
     
    Copy the script below into a file named whatever you choose, place it where you want to run it, and cron it to get it going.  It should only create disk writes when the power is out or when shutting down from battery drain on no A/C (a few lines once per minute), and will create no disk writes  if you comment out the logging.
     
     
    Let me know how it works for you, if you use it.  I've been testing it for the past couple of days, and it's worked as intended.  I'm always open to code tips, and I'm still learning, so any advice is appreciated.