[systemd-devel] Script in system-sleep that makes an HTTP post

Doug Koobs dkoobs at dkoobs.com
Fri Jun 11 14:50:34 UTC 2021


Hello all,

tldr: Is there way I can use systemd to run scripts in 
/usr/lib/systemd/system-sleep at suspend before disabling the network?

I've put a script in /usr/lib/systemd/system-sleep that makes an HTTP 
post to an IFTTT webhook when it's passed "pre" as $1. The script is 
successful if I run it manually, but when systemd runs it when I suspend 
the laptop, running "journalctl -b -u systemd-suspend.service" reports:

     /usr/lib/systemd/system-sleep/outlet.sh failed with exit status 6.

perror defines exit status 6 as: OS error code   6:  No such device or 
address

This sounds like a network problem. If I disable networking and manually 
run the script, I get:

     curl: (6) Could not resolve host: maker.ifttt.com

My assumption is that systemd disables networking before the 
system-sleep scripts are run. Is there way I can use systemd to run the 
script before disabling the network?

Thanks!

Doug



More information about the systemd-devel mailing list