You are not logged in.
I'm testing a custom unit file to run some post-resume script, but it seems that the service was not triggered at all.
1. The script: /home/user/bin/test.sh
#!/bin/bash
date >> /home/user/test.logAnd made it executable by chmod +x /home/user/bin/test.sh
2. The custom service file: /etc/systemd/system/custom.service
[Unit]
Description=Local system resume actions
After=sleep.target
[Service]
Type=simple
ExecStart=/home/user/bin/test.sh
[Install]
WantedBy=sleep.targetEnabled it by systemctl enable custom.service, and it returns success.
systemctl start custom.service runs the script just fine, a test.log appeared in my home folder which indicates the service ran as expected. And there is corresponding log entries in journalctl -u custom.service.
Check the state by systemctl status custom.service:
● custom.service - Local system resume actions
Loaded: loaded (/etc/systemd/system/custom.service; enabled; vendor preset: enabled)
Active: inactive (dead)Which seems to be A-OK.
But upon waking from suspend, the script was not run, and nothing appeared at journalctl -u custom.service, which means the service was not triggered at all?
I'm running out of ideas, what did I do wrong? ![]()
Thanks!
Offline
Try the following logic:
Before=sleep.target but After=suspend.target.
Offline
Try the following logic:
Before=sleep.target but After=suspend.target.
Thanks.
I changed the unit file to:
[Unit]
Description=Local system resume actions
Before=sleep.target
After=suspend.target
... ...
... ...then
systemctl daemon-reload
systemctl restart custom.service
pm-suspendStill not working. ![]()
Any ideas?
EDIT: I know some workarounds by using pm-utils hooks or systemd-suspend hooks, but I'd like to solve it in the unit files. ![]()
Last edited by alexspb21 (2015-07-08 09:21:57)
Offline
Yes. You want this thing to run after resume. Have a look at the power management wiki article, especially the "Suspend/resume service files" section.
Offline
Ok, now it works, but inconsistently.
Use
systemctl suspend to suspend seems to have triggered the script.
But when I changed
ExecStart=/home/user/bin/test.shto
ExecStart=/usr/bin/hdparm -B 254 -S 0 /dev/sdaIt didn't work.
Manually run the service seems to work fine again.
Now reading https://wiki.archlinux.org/index.php/Po … vice_files
Offline