Re: convert crontab jobs to systemd timers

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

 



On 4/8/22 05:43, olivares33561 via users wrote:
Sent from ProtonMail, encrypted email based in Switzerland.
------- Original Message -------
On Friday, April 8th, 2022 at 5:13 AM, Barry Scott <barry@xxxxxxxxxxxxxxxx> wrote:


On 7 Apr 2022, at 21:22, olivares33561 via users users@xxxxxxxxxxxxxxxxxxxxxxx wrote:

Sent from ProtonMail, encrypted email based in Switzerland.

I am getting closer.

[olivares@fedora user]$ cat poweroff.service
# /etc/systemd/system/poweroff.service
[Unit]
Description = Poweroff machine at 16:20 PM Mo-Fri

[Service]
Type=oneshot
#ExecStart=~/bin/poweroff.sh
ExecStart=/usr/bin/sudo /usr/bin/systemctl --no-block poweroff.service


To power down the system you can use the command
Best Regards,


Antonio
_______________________________________________
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


/usr/bin/systemctl poweroff

See man systemctl for the details of what this does.

Barry


[olivares@fedora user]$ cat poweroff.timer
# /etc/systemd/system/poweroff.timer
[Unit]
Description=Poweroff machine at 4:20 PM Mo-Fri

[Timer]
OnCalendar=Mon..Fri --* 16:20:00
Persistent=true

[Install]
WantedBy=timers.target

I get the following error message:

[olivares@fedora user]$ systemctl --user enable poweroff.service
The unit files have no installation config (WantedBy=, RequiredBy=, Also=,
Alias= settings in the [Install] section, and DefaultInstance= for template
units). This means they are not meant to be enabled using systemctl.

Possible reasons for having this kind of units are:
• A unit may be statically enabled by being symlinked from another unit's
.wants/ or .requires/ directory.
• A unit's purpose may be to act as a helper for some other unit which has
a requirement dependency on it.
• A unit may be started when needed via activation (socket, path, timer,
D-Bus, udev, scripted systemctl call, ...).
• In case of template units, the unit is meant to be enabled with some
instance name specified.
[olivares@fedora user]$

Thank you all for helping me.

Best Regards,

Antonio

I have modified poweroff.service and added the line

[olivares@fedora user]$ cat poweroff.service
# /etc/systemd/system/poweroff.service
[Unit]
Description = Poweroff machine at 16:20 PM Mo-Fri

[Service]
Type=oneshot
#ExecStart=~/bin/poweroff.sh
#ExecStart=/usr/bin/sudo /usr/bin/systemctl --no-block poweroff.service
ExecStart=/usr/bin/systemctl poweroff
[olivares@fedora user]$ cat poweroff.timer
# /etc/systemd/system/poweroff.timer
[Unit]
Description=Poweroff machine at 4:20 PM Mo-Fri

[Timer]
OnCalendar=Mon..Fri *-*-* 07:45:00
Persistent=true

[Install]
WantedBy=timers.target
[olivares@fedora user]$

however, when I try to enable the service I get

[olivares@fedora user]$ mcedit poweroff.service

[olivares@fedora user]$ mcedit poweroff.timer

[olivares@fedora user]$ systemctl --user enable poweroff.service
The unit files have no installation config (WantedBy=, RequiredBy=, Also=,
Alias= settings in the [Install] section, and DefaultInstance= for template
units). This means they are not meant to be enabled using systemctl.

Possible reasons for having this kind of units are:
• A unit may be statically enabled by being symlinked from another unit's
   .wants/ or .requires/ directory.
• A unit's purpose may be to act as a helper for some other unit which has
   a requirement dependency on it.
• A unit may be started when needed via activation (socket, path, timer,
   D-Bus, udev, scripted systemctl call, ...).
• In case of template units, the unit is meant to be enabled with some
   instance name specified.
[olivares@fedora user]$

I changed 16:20:00 to 07:45:00 for testing purposes.  But this is what I get.  I just want a service that powers off machine using this method.  The crontab method of shutting down the machine worked before, but now fails too.  I don't have any crontab entries anymore to make sure it does not affect/compete with systemd-timer.

[olivares@fedora user]$ crontab -l
[olivares@fedora user]$


Please be so kind as to share your solution.
_______________________________________________
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