O que poderia estar errado?
Arquivo /home/user/bin/kill-chrome
:
#!/usr/bin/env bash
HOME_DIR='/home/user/'
TEST_FILE="${HOME_DIR}systemd-test.log"
#this doesn't work with systemd unit, but works as cli command:
/usr/bin/pkill --signal SIGTERM chrome
/usr/bin/pkill --signal SIGTERM chromium-browser
#this works fine with systemd unit:
/bin/echo 'date' >> "$TEST_FILE"
Arquivo /lib/systemd/system/kill-chrome.service
:
[Unit]
Description=kill-chrome
Before=reboot.target shutdown.target halt.target
DefaultDependencies=no
[Service]
Type=oneshot
ExecStart=/bin/true
ExecStop=/home/user/bin/kill-chrome
RemainAfterExit=true
StandardOutput=journal
[Install]
WantedBy=multi-user.target
Não há erros / avisos no journalctl.