My observation is that putting `apm -a` or `apm -b` into `/etc/apm/powerup` breaks `apm`.
My actions, with `-av` for clarity: 0. Try `apm -av` to see it works. 1. Make `/etc/apm/powerup` like this: #! /bin/sh apm -av >> /tmp/apm_powerup 2>&1 2. Check it works: /bin/sh /etc/apm/powerup 3. Follow `/tmp/apm_powerup`, you should see the output from previous step there: tail -f /tmp/apm_powerup 4. Enact the `/etc/apm/powerup` by (re)starting `apmd` and look what is running: rcctl restart apmd && ps auxw | grep apm You should see `/usr/sbin/apmd` in the output 5. Wait awhile coz `/etc/apm/powerup` doesn't get executed immediately. Try `ps auxw | grep apm` until you see `/bin/sh /etc/apm/powerup` & `apm -av` alongside `/usr/sbin/apmd` 6. Watch your `tail -f /tmp/apm_powerup` - nothing appears there 7. Try `apm -av` from another terminal - it hangs 8. `rcctl stop apmd` (or `rcctl restart apmd`) 9. I get in both `/tmp/apm_powerup` and hung `apm -av`: apm: invalid reply from APM daemon: Undefined error: 0 apm: cannot get reply from APM daemon Expected outcome would be: Identical output from: `apm -av` manually, `/bin/sh /etc/apm/powerup` manually & `/bin/sh /etc/apm/powerup` automatically Actually, `apm -av` manually & `/bin/sh /etc/apm/powerup` manually work fine and give identical output whereas `/bin/sh /etc/apm/powerup` automatically - hangs. Please note that not only `apm -a` or `apm -b` but also `zzz` & `ZZZ` get broken this way. Incidentally, I checked quoting: interactively you do need surrounding quotes like this: /bin/sh -c '[ "$(apm -av)" = "A/C adapter state: connected" ] && anacron -ds' whereas in `crontab` you need not surrounding quotes, this is fine: 30 1 * * * [ "$(apm -av)" = 'A/C adapter state: connected' ] && anacron -ds and if you do put surrounding quotes in `crontab` like this: 30 1 * * * '[ "$(apm -av)" = "A/C adapter state: connected" ] && anacron -ds' the job will not be done. So my mistakes were @-strings in `anacrontab` and `PATH` in `crontab`, both unrelated to the `apm` issue
