10.12.2024 01:16, Kenneth Porter via Postfix-users wrote:
I have a systemd unit on another distro that submits mail with /bin/mail (part of mailx) at boot and shutdown. What dependencies are needed to make that work here? (This notifies me when a remote system comes up that it was gracefully shut down and is now up again, and when that happened.)
You haven't specified the *state* of shutdown you want to send mail at. Because there are differences, be it systemd or anything else. You might send mail at the *start* of shutdown, when all services are running still, just as an indicator that we initiated a shutdown procedure. This is one thing. And you might want to send email riiight before the final poweroff, when all filesystems are already unmounted and root switched to read-only mode. And this mail will include logs from whole system shutdown process. This is entirely different thing, obviously. With dependency-based system, the 2nd variant is probably possible too (but you can't send mail with /bin/mail or postfix here quite obviously since there's no writable /var anymore) - you'll have to depend on network and use submission over smtp. Or there's a simpler in-between version: you depend on local-fs.target, be part of the right target in the shutdown sequence (I don't remember off-hand which one, these things are rarely used). And just send mail the normal way, relying on postfix saving it to the spool dir to be sent at later time. As for the startup email, I have it using a timer, so that I see all logs after everything is settled down already: bootinfo.timer: [Timer] OnBootSec=60 [Install] WantedBy=timers.target bootinfo.service: [Unit] Description=Collect System Boot Info [Service] Type=oneshot ExecStart=/etc/tls/bootinfo.sh This one collects some info about current boot including boot logs, and sends it by email. You enable it lie systemctl enable bootinfo.timer. Thanks, /mjt _______________________________________________ Postfix-users mailing list -- postfix-users@postfix.org To unsubscribe send an email to postfix-users-le...@postfix.org