At 5am cron runs shutdown, systemd executed /home/myuser/bin/mailme-shutdown.sh and my pc poweroff. When I startup the pc an email coming to me. The email is the script (mailme-shutodown.sh) executed before I powered up the pc. Any idea to send email before pc shutdown? I use local postfix with external smtp service.
cat /etc/crontab
00 05 * * * root /sbin/shutdown -h now
[Unit]
Description=Run command at shutdown
Requires=network.target
Before=shutdown.target reboot.target halt.target
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/home/myuser/bin/mailme-startup.sh
ExecStop=/home/myuser/bin/mailme-shutdown.sh
User=myuser
[Install]
#WantedBy=multi-user.target
WantedBy=halt.target reboot.target shutdown.target
cat mailme-shutdown.sh
[...]
[email protected]
echo "body" | mail -s "test" "$email"
[...]