Re: Inhibit sleep from systemd service

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 22/03/2021 14:08, Ed Greshko wrote:
But, when testing things I like to use examples which use simple system commands.  To verify that things
work as I think they should in various ways before trying my commands/scripts.

Along those lines....

[egreshko@f33k ~]$ cat /etc/systemd/system/mycron.timer
[Unit]
Description=Test Cron

[Timer]
OnCalendar=*:00/10
Persistent=True

[Install]
WantedBy=timers.target

[egreshko@f33k ~]$ cat /etc/systemd/system/mycron.service
[Unit]
Description=Testing myCron

[Service]
Type=oneshot
#ExecStart=/usr/bin/touch /var/tmp/auto/myCron
ExecStart=/usr/bin/systemd-inhibit --who=ME --why=whynot /usr/bin/sleep 300


And when the time arrives

[root@f33k system]# date
Mon Mar 22 07:20:05 PM CST 2021

[root@f33k system]# systemctl status mycron.timer
● mycron.timer - Test Cron
     Loaded: loaded (/etc/systemd/system/mycron.timer; enabled; vendor preset: di>
     Active: active (running) since Mon 2021-03-22 19:00:42 CST; 19min ago
    Trigger: n/a
   Triggers: ● mycron.service

Mar 22 19:00:42 f33k.greshko.com systemd[1]: Started Test Cron.

[root@f33k system]# ps -eaf | grep 300
root        1305       1  0 19:20 ?        00:00:00 /usr/bin/systemd-inhibit --who=ME --why=whynot /usr/bin/sleep 300
root        1308    1305  0 19:20 ?        00:00:00 /usr/bin/sleep 300

[root@f33k system]# systemd-inhibit --list
WHO            UID USER PID  COMM            WHAT WHY             >
ME             0   root 1305 systemd-inhibit shutdown:sleep:idle whynot          >
ModemManager   0   root 577  ModemManager    sleep ModemManager nee>
NetworkManager 0   root 703  NetworkManager  sleep NetworkManager n>
UPower         0   root 598  upowerd         sleep Pause device pol>

4 inhibitors listed.



--
People who believe they don't make mistakes have already made one.

_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux