First of all: you are running Raspbian Stretch but tagged the question with pi-4
. This is not possible. A Raspberry Pi 4B can only run Raspbian Buster.
Your timer Unit looks good and should do. But you define some default settings that are not necessary. This normally should not do any harm, but having problems it's always a good idea to configure with defaults. I have tested it with Raspbian Buster Light.
A systemd timer Unit calls by default a service of the same name, so a timer Unit named systemd-poweroff.timer
will call a service of systemd-poweroff.service
if not specified otherwise. So first check if this service is working as expected:
rpi ~$ sudo systemctl start systemd-poweroff.service
Then the last messages on my screen are:
--- snip ---
[ OK ] Reached target Shutdown.
[ OK ] Reached target Final Step.
[ OK ] Started Power-Off.
[399078.812158] reboot: Power down
I have to powercycle to restart the RasPi.
Then I created the timer with:
rpi ~$ sudo systemctl --force --full edit systemd-poweroff.timer
In the empty editor I inserted these statements, saved them and quit the editor:
[Unit]
Description=Poweroff every work day
[Timer]
#OnCalendar=Mon,Tue,Wed,Thu,Fri *-*-* 00:00:00
OnBootSec=180
[Install]
WantedBy=timers.target
For testing I used OnBootSec=180
, which will poweroff the RasPi 3 minutes after bootup. Enable it now will poweroff the RasPi immediately because 3 minutes are already gone since last bootup.
rpi ~$ sudo systemctl enable --now systemd-poweroff.timer
This works as expected. I have to powercycle to restart the RasPi.
Check and stop the poweroff timer. You have 3 minutes to do it ;-)
rpi ~$ systemctl list-timers systemd-poweroff.timer
NEXT LEFT LAST PASSED UNIT ACTIVATES
Tue 2020-05-26 12:40:28 BST 1min 5s left n/a n/a systemd-poweroff.timer systemd-poweroff.service
1 timers listed.
rpi ~$ sudo systemctl disable --now systemd-poweroff.timer
systemd-halt.service
.systemctl halt
I ended up having a python program responding to mqtt and the scheduled task pushing the mqtt command!