-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wednesday, 2022-03-02 at 22:00 +0300, Andrei Borzenkov wrote:
On 02.03.2022 17:45, Carlos E. R. wrote:
On Wednesday, 2022-03-02 at 12:56 +0100, Parodper wrote:
O 02/03/22 ás 12:49, Dave Howorth escribiu:
On Wed, 2 Mar 2022 12:26:04 +0100 (CET) "Carlos E. R." <> wrote:
Long ago we decided there was no way to do it. Is there now some way?
Surely it's easy? You just have a script always running
Instead of always running, you can try to create a systemd unit that runs after hibernate.target.
Maybe examine "systemctl status hibernate.target" output.
cer@Telcontar:~> systemctl status hibernate.target ● hibernate.target - Hibernate Loaded: loaded (/usr/lib/systemd/system/hibernate.target; static) Active: inactive (dead) Docs: man:systemd.special(7)
Feb 28 10:23:51 Telcontar systemd[1]: Reached target Hibernate. Feb 28 10:23:51 Telcontar systemd[1]: Stopped target Hibernate. Feb 28 17:53:35 Telcontar systemd[1]: Reached target Hibernate. Feb 28 17:53:35 Telcontar systemd[1]: Stopped target Hibernate. Feb 28 20:24:14 Telcontar systemd[1]: Reached target Hibernate. Feb 28 20:24:14 Telcontar systemd[1]: Stopped target Hibernate. Mar 01 12:00:50 Telcontar systemd[1]: Reached target Hibernate. Mar 01 12:00:50 Telcontar systemd[1]: Stopped target Hibernate. Mar 02 03:38:31 Telcontar systemd[1]: Dependency failed for Hibernate. Mar 02 03:38:31 Telcontar systemd[1]: hibernate.target: Job hibernate.target/start failed with result 'dependency'. cer@Telcontar:~>
Notice that the status itself is not failed, so can't be used.
Targets cannot fail, they are either active or not. Still, systemd will start units listed in target's OnFailure when target start job failed.
Ah. Retrying on automatic might be an endless loop impossible to stop. Maybe if it tried only once. Is it possible to list all such units in a target? Telcontar:~ # systemctl cat hibernate.target # /usr/lib/systemd/system/hibernate.target ... [Unit] Description=Hibernate Documentation=man:systemd.special(7) DefaultDependencies=no Requires=systemd-hibernate.service After=systemd-hibernate.service StopWhenUnneeded=yes Telcontar:~ # Telcontar:~ # systemctl cat sleep.target # /usr/lib/systemd/system/sleep.target ... [Unit] Description=Sleep Documentation=man:systemd.special(7) DefaultDependencies=no RefuseManualStart=yes StopWhenUnneeded=yes Telcontar:~ # Ah, wait... you say "Still, systemd will start units listed in target's OnFailure when target start job failed". So, maybe edit "sleep.target" Telcontar:~ # systemctl cat sleep.target # /usr/lib/systemd/system/sleep.target ... [Unit] Description=Sleep Documentation=man:systemd.special(7) DefaultDependencies=no RefuseManualStart=yes StopWhenUnneeded=yes # /etc/systemd/system/sleep.target.d/override.conf OnFailure=sleepfailure.service Telcontar:~ # Telcontar:~ # systemctl edit --force --full sleepfailure.service ... Telcontar:~ # systemctl cat sleepfailure.service # /etc/systemd/system/sleepfailure.service [Unit] Description=Plays something when sleep.target fails #After=sleep.target Do not want to run always. [Service] Type=oneshot RemainAfterExit=true StandardOutput=tty ExecStart=-/root/ThingsNeededForBoot/sleepfailed Telcontar:~ # Telcontar:~/ThingsNeededForBoot # cat sleepfailed #!/bin/bash # -x su cer -c "XDG_RUNTIME_DIR=/run/user/1000 aplay /usr/local/share/cosas/abitsilly.wav" /usr/bin/logger -t Mine -p daemon.info "Something failed on hibernate, sound play." Telcontar:~ # systemctl status sleepfailure.service ● sleepfailure.service - Plays something when sleep.target fails Loaded: loaded (/etc/systemd/system/sleepfailure.service; static) Active: inactive (dead) Telcontar:~ # Well, we'll see if it works :-) Thanks for the idea. - -- Cheers, Carlos E. R. (from openSUSE 15.3 x86_64 at Telcontar) -----BEGIN PGP SIGNATURE----- iHoEARECADoWIQQZEb51mJKK1KpcU/W1MxgcbY1H1QUCYh/LDxwccm9iaW4ubGlz dGFzQHRlbGVmb25pY2EubmV0AAoJELUzGBxtjUfVo/MAoISeWDNSXnlAfLl+pLY5 EsAZQUpdAJ4kA1/k5LmKQoo1vWfRymTaMKxuQg== =EmHN -----END PGP SIGNATURE-----