APCCONTROL(8)
π APCCONTROL(8) β the manual page, but make it make sense π
okay bestie, welcome to APCCONTROL(8) from the System Manager's Manual π this is part one of two so don't go anywhere, we're just getting started β¨
πΈ NAME πΈ
apccontrol β the event handler script for apcupsd(8). she's the one who takes action when your UPS starts acting up, no cap π«Ά
β SYNOPSIS β
apccontrol { <event> <ups-name> <connected> <powered> }
π DESCRIPTION π
so here's the vibe. when apcupsd(8) clocks something sus coming off the UPS it's monitoring, it fires off an event, and that event usually means one or more calls to the apccontrol shell script. every event makes apccontrol do a specific thing. and the default behaviour? honestly iconic, it's sane for basically every event apcupsd is likely to run into. but β and this is the good part β you can change the behaviour of every single action. every one. periodt π
when apcupsd spots an event, it calls the apccontrol script with these four arguments, in this order:
eventβ the event that just happened. go peep the list of possible events below πups-nameβ the name of the UPS as specified in the/etc/apcupsd/apcupsd.confconfiguration file. and like, not the name in the EEPROM of a smart UPS, okay? different thing, don't get it twisted πconnectedβ this is1ifapcupsdis connected to the UPS via a serial or USB port. on a slave machine whereapcupsdisn't directly connected to the UPS? then this value is0.poweredβ this is1if the computer runningapcupsdis powered by the UPS, and0if not. heads up though: this is not currently implemented and always defaults to0. yeah. she's aspirational π
events get sent to the system log and, optionally, to the temporary events file (/etc/apcupsd/apcupsd.events). they also trigger a call to apccontrol, which in turn will call any scripts you've dropped into the /etc/apcupsd directory. the whole pipeline is giving main character energy fr fr π₯
β¨ LIST OF EVENTS AND DEFAULT ACTIONS β¨
annoymeβapcupsdfires this one when a shutdown is scheduled and the time specified by theANNOYMEconfiguration directive in the/etc/apcupsd/apcupsd.conffile has expired.
Default action β sends "Power problems please logoff." to wall(1) and then exits. she's annoying you on purpose, that's the whole point π£οΈ
battattachβapcupsdfires this when it detects the UPS battery has been reconnected after abattdetachevent.
Default action: does nothing. chill. unbothered. πΈ
battdetachβapcupsdfires this when it detects the UPS battery has been disconnected.
Default action: does nothing. also just vibing π¦
changemeβapcupsdfires this when it detects the utility power is on, but the battery is not functioning correctly. this one repeats every 9 hours. every. nine. hours. she will not let it go π€
Default action β sends "Emergency! UPS batteries have failed Change them NOW" to wall and then exits. she is yelling. respectfully. π
commfailureβapcupsdfires this each time it loses communication with the monitored UPS. note: this event is not detected on simple signalling UPSes like theBack-UPS 650.
Default action β sends "Communications with UPS lost." to wall and then exits. ghosted by your own UPS π
commokβapcupsdfires this after acommfailureevent, when communication with the UPS is re-established.
Default action β sends "Communications with UPS restored." to wall and then exits. we love a comeback story π«Ά
dorebootβ this event is deprecated and should not be used. like, do not. β οΈ
Default action β sends "Beginning Reboot Sequence" to wall and then calls shutdown(8) with the "-r now" command line arguments to reboot the computer.
doshutdownβapcupsdfires this to shut the computer down when the UPS is running on battery power and one of the limits (time, run, load) has been reached.
Default action β sends "Beginning Shutdown Sequence" to wall and then calls shutdown(8) with the command line arguments "-h now" to shut the computer down.
emergencyβapcupsdfires this when the UPS is on battery power, the battery is low, and the utility power is on. that combination? a sure sign of battery failure π¨
Default action β sends "Emergency Shutdown. Possible UPS battery failure." to wall. immediately after this, apcupsd generates a doshutdown event to shut the system down.
failingβapcupsdfires this when the UPS is running on batteries and the UPS sets the low battery signal, indicating battery power is nearly exhausted. after this event,apcupsdwill immediately generate adoshutdownevent.
Default action β sends "UPS battery power exhausted. Doing shutdown." to wall and then exits.
killpowerβapcupsddoes not normally generate this event. instead, it's invoked directly from the system halt script as'apccontrol killpower', because thekillpowerevent needs to happen as late in system shutdown as possible. she's the final boss of shutdown π§
Default action β sends "UPS now committed to shut down" to wall, waits for 10 seconds, and then issues the command "apcupsd --killpower" to put the UPS into hibernate mode and shut off power to the connected equipment. in the case of a smart UPS, the UPS will then wait for the expiry of any configured shutdown time delay specified by the SLEEP configuration directive. in hibernate mode, the UPS will restore utility power to the connected equipment subject to the values specified for the RETURNCHARGE and WAKEUP configuration directives. yes that's a lot of directives, write them down π
loadlimitβapcupsdfires this when the battery discharge limit specified by theBATTERYLEVELconfiguration directive has been reached.
Default action β sends "UPS battery discharge limit reached. Doing shutdown" to wall and then exits. after this event, apcupsd will immediately generate a doshutdown event.
mainsbackβapcupsdfires this when the utility power returns after apoweroutevent. whether thedoshutdownevent got generated depends on the parameters you've defined and how long the outage was. and listen: attempting cancellation of adoshutdownevent should never be tried, because it's very unlikely to succeed and will almost certainly leave your computer in an indeterminate state. do not do it. that's the rule π
Default action β if the file /var/run/powerfail exists, sends "Continuing with shutdown." to wall and then exits. otherwise, does nothing.
onbatteryβapcupsdfires this if a power failure has been detected and the UPS is still on battery power at the expiry of the delay specified by theONBATTERYDELAYconfiguration directive.
Default action β sends "Power failure. Running on UPS batteries." to wall and then exits.
offbatteryβapcupsdfires this when the utility power returns, if and only if theonbatteryevent has been generated.
Default β sends ""Power has returned..." to wall and then exits. (yes, those quotes are exactly like that in the original, we don't fix, we report π
)
poweroutβapcupsdfires this as soon as it detects the UPS has switched to battery power, and it's not a self-test.
Default action β does nothing. just a lil heads up β¨
remotedownβapcupsdfires this on a slave machine when it detects either (1) that the master has shut down, or (2) that anonbatteryevent has occurred and communication with the master has been lost.
Default action: sends "Remote Shutdown. Beginning Shutdown Sequence." to wall and exits. immediately after this, apcupsd generates a doshutdown event to shut the system down.
runlimitβapcupsdfires this when the remaining runtime limit specified by theMINUTESconfiguration directive expires while the UPS is on battery power as the result of a utility power outage. the remaining runtime is internally calculated by the UPS and monitored byapcuspd. (that's how it's spelled in the original, iykyk π)
Default action β sends "UPS battery runtime percent reached. Doing shutdown." to wall and then exits. after this event, apcupsd will immediately generate a doshutdown event.
timeoutβapcupsdfires this when the time specified by theTIMEOUTconfiguration directive expires while the UPS is on battery power as the result of a utility power outage. this configuration directive is not normally used with smart UPSes, which would instead rely on the more reliable remaining runtime (MINUTES) or the battery level (BATTERYLEVEL) configuration directives. smart UPSes said "we have better options" π
Default action β send "UPS battery runtime limit exceeded. Doing shutdown." to wall and then exits. after this event, apcupsd will immediately generate a doshutdown event.
startselftestβapcupsdfires this when it detects the start of a UPS self test.
Default action: does nothing. she's just watching π§
endselftestβapcupsdfires this when it detects the end of a UPS self test.
Default action: does nothing. all done, no notes π
π CUSTOMISING EVENT ACTIONS π
Do not modify apccontrol directly, bestie, because it will be overwritten the next time you upgrade to a new release of apcupsd. we are NOT losing your hard work to an upgrade. never π
the recommended way to customise an event action is simply to create an executable program or script file with the same name as the event, and put that file in the /etc/apcupsd directory. now, when the selected event occurs, apccontrol will execute your program or script. so easy. so clean. obsessed π«Ά
if you want apccontrol to also execute its default action for the selected event, your program or script should exit with an exit status of 0 (zero). both things happen, everyone eats π
if you do not want apccontrol to also execute its default action for the selected event, your program or script must exit with an exit status of 99. but be aware β if you completely override the default action, you must ensure the proper shutdown of your computer if this is necessary. that's on you now, queen π
some sample scripts (changeme, commfailure, commok, offbattery and onbattery) that email messages to root instead of broadcasting messages to all logged-in users may be found in /etc/apcupsd after an installation, and also in the platforms/etc directory of the apcupsd source code. free templates, go off π
π FILES π
/etc/apcupsd/apccontrol
okay that's the first half, stay tuned for part two, we're not done yet β¨
π SEE ALSO β go read these too bestie
Like, don't just stop here, the lore goes deep:
wall(1)β for shouting at everybody's terminal at once π¬apcupsd.conf(5)β the config file that runs the whole show πapcupsd(8)β the daemon herself, the main character πshutdown(8)β what actually happens when the power dips π
Also?? There's a whole HTML apcupsd manual that's installed on your system, and if you don't have it locally you can grab it online at http://www.apcupsd.org/ β¨ It's giving documentation, it's giving resources, it's giving everything you need fr fr.
π AUTHORS β the icons who made this happen
π This page
- Trevor Roydhouse β wrote the page you're literally reading rn π«Ά
π¦ Software
- Adam Kropelin β current Project Manager and Code Maintainer π§ (yes, present tense, he's that girl)
- Kern Sibbald β former Project Manager and Code Maintainer πΈ
- Riccardo Facchetti β former Project Manager and Code Maintainer π
- Andre M. Hedrick β Project Founder and former Code Maintainer β like, the actual origin story
π Contributors
- An enormous number of users who have devoted their time and energy to this project β thanks ππ no cap, genuinely, every single one of them ate π
okay bestie that's the whole page, you made it to the end, iconic behavior, 10/10 no notes πβ¨
apccontrol v3.14.6 β January 10, 2009 π (yes it's been iconic since 2009 and it still slays, we love a timeless queen π)
π¦ where this page comes from
- alpine 3.22: apcupsd-doc 3.14.14-r6 Β· GPL-2.0-or-later
- alpine 3.23: apcupsd-doc 3.14.14-r6 Β· GPL-2.0-or-later
- alpine 3.24: apcupsd-doc 3.14.14-r6 Β· GPL-2.0-or-later
- arch rolling: apcupsd 3.14.14-9 Β· GPL
- debian bookworm: apcupsd 3.14.14-3.1+b1 Β· GPL-2.0-or-later
- debian trixie: apcupsd 3.14.14-5 Β· GPL-2.0-or-later
- epel 10: apcupsd 3.14.14-36.el10_1 Β· GPL-2.0-only
- epel 9: apcupsd 3.14.14-35.el9 Β· GPL-2.0-only
- fedora 43: apcupsd 3.14.14-39.fc43 Β· GPL-2.0-only
- fedora 44: apcupsd 3.14.14-41.fc44 Β· GPL-2.0-only
- nixos 26.05: apcupsd 3.14.14
- nixpkgs unstable: apcupsd 3.14.14
- opensuse-leap 16.0: apcupsd 3.14.14-bp160.1.1 Β· GPL-2.0-only
- opensuse-leap 16.0: apcupsd 3.14.14-bp160.1.1 Β· GPL-2.0-only
- opensuse-leap 16.0: apcupsd 3.14.14-bp160.1.1 Β· GPL-2.0-only
- opensuse-leap 16.0: apcupsd 3.14.14-bp160.1.1 Β· GPL-2.0-only
- ubuntu jammy: apcupsd 3.14.14-3.1build1 Β· GPL-2.0-or-later
- ubuntu noble: apcupsd 3.14.14-3.1build2 Β· GPL-2.0-or-later
- ubuntu questing: apcupsd 3.14.14-5
- ubuntu resolute: apcupsd 3.14.14-7 Β· GPL-2.0-or-later
- ubuntu stonking: apcupsd 3.14.14-7build1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms