Re: convert crontab jobs to systemd timers

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

 




> On 7 Apr 2022, at 19:53, olivares33561 via users <users@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
> 
> Sent from ProtonMail, encrypted email based in Switzerland.
> 
> 
> ------- Original Message -------
> On Wednesday, April 6th, 2022 at 8:09 PM, Tim via users <users@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
> 
> 
>> On Tue, 2022-04-05 at 20:18 +0000, olivares33561 via users wrote:
>> 
>>> How can I convert a crontab
>>> #
>>> [olivares@fedora Downloads]$ crontab -l
>>> # min hour day-of-month month day-of-week command
>>> # 0-59 0-23 1-31 1-12 0-6 0=sun 1=mon
>>> #50 04 * * 1-5 ~/.xalarm >/dev/null 2>&1
>>> #50 04 * * 0,6 ~/.salarm >/dev/null 2>&1
>>> #59 09 * * 0,6 ~/.salarm >/dev/null 2>&1
>>> #00 07 * * 1-5 ~/.xalarm >/dev/null 2>&1
>>> 42 08 * * 1-5 ~/.dalarm >/dev/null 2>&1
>>> 52 09 * * 1-5 ~/.dalarm >/dev/null 2>&1
>>> 40 10 * * 1-5 ~/.dalarm >/dev/null 2>&1
>>> 28 11 * * 1-5 ~/.dalarm >/dev/null 2>&1
>>> 16 12 * * 1-5 ~/.dalarm >/dev/null 2>&1
>>> 57 12 * * 1-5 ~/.dalarm >/dev/null 2>&1
>>> 40 14 * * 1-5 ~/.dalarm >/dev/null 2>&1
>>> 28 15 * * 1-5 ~/.dalarm >/dev/null 2>&1
>>> 17 16 * * 1-5 ~/.dalarm >/dev/null 2>&1
>>> #30 16 * * 1-5 ~/.lalarm > /dev/null 2>&1
>>> 25 16 * * 1-5 /usr/sbin/poweroff >/dev/null 2>&1
>>> 
>>> #
>>> to systemd timers? An easy idiot proof way. The .dalarm script
>>> calls mplayer and plays from a playlist.
>> 
>> 
>> Tangentially, can you get mplayer to make sounds when it's not you
>> that runs it? i.e. A system user rather than a real user.
>> 
>>> I have read https://opensource.com/article/20/7/systemd-timers
>>> and https://www.maketecheasier.com/use-systemd-timers-as-cron-replacement/
>>> 
>>> but have not tried it out. Any help on this is appreciated.
>> 
>> 
>> You could look at this, too:
>> https://wiki.archlinux.org/title/Systemd/Timers
>> Archlinux docs often get good recommendations
>> 
>> NB: I've only just looked at this just now, I've only ever done the
>> odd crontab thing a few times. Each time I have to work it out.
>> 
>> --
>> 
>> uname -rsvp
>> Linux 3.10.0-1160.59.1.el7.x86_64 #1 SMP Wed Feb 23 16:47:03 UTC 2022 x86_64
>> 
>> Boilerplate: All unexpected mail to my mailbox is automatically deleted.
>> I will only get to see the messages that are posted to the mailing list.
> 
> Thanks to all who have responded.  I am trying it out, but I have it not working.  I created a poweroff.service and poweroff.timer.
> 
> [olivares@fedora ~]$ cat /etc/systemd/system/poweroff.service
> # /etc/systemd/system/poweroff.service
> [Unit]
> Description = Poweroff maschine at 16:20 PM Mo-Fri
> 
> [Service]
> Type=oneshot
> ExecStart=sudo systemctl poweroff

You might need to use systemctl --no-block start poweroff.
The --no-block I recall is needed to stop systemd getting into a dependency cycle.

Below you have this error:

> Apr 07 13:42:36 fedora systemd[24819]: poweroff.service: Failed to locate executable sudo: No such file or directory


You did not tell systemd where to find "sudo" try this:

ExecStart=/usr/bin/sudo /usr/bin/systemctl --no-block poweroff.service

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