On 4/6/22 10:50, olivares33561 via users wrote:
I have a crontab file that I use to play some files about 3 minutes before bell rings between classes. I had to install anacron with dnf command. I have seen emails where some folks recommend systemd timers. How can I convert a crontab
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.
Sorry for brutalizing the thread but I'd already deleted the earlier emails.
Nothing is idiot proof.
A conversion script wouldn't be trivial. In general, each line in the
crontab would have to generate two separate systemd files: a .timer and
an associated .service file. If there are multiple calls to the same
command they can be combined into one timer.
While Systemd's timer system is extraordinarily flexible it requires
multiple files to do anything.
Here's a personal example. I have two apps that connect directly to the
Master on the audio mixer and when they go off it wakes up the neighbors
so I want them to be muted for 3 seconds twice a day Monday thru Friday.
That requires four files: mute.timer and mute.service, and
unmute.timer and unmute.service. I set them up as --user files.
For something simple like crontab entries you could probably create a
couple of generic .timer and .service files and by changing one or two
lines in them per timer have them working across the board.
The way I see it is that is the easiest way to go. I haven't found a
script that does the conversion so I took the time to figure out how to
do it (turns out it's not difficult) and now have all my periodic
services using systemd timers.
One very nice feature is that you can specify multiple "calendar" events
in the same timer so all of the ~/.dalarm crontab entries would exist in
one timer, ~/.xalarm files in another, etc. Each of those timers would
have one service file for a total of eight files, in your case:
dalarm.timer
lalarm.timer
salarm.timer
xalarm.timer
dalarm.service
lalarm.service
salarm.service
xalarm.service
Note: learning about systemd timers might help people hate systemd a bit
less.
hth,
mike wright
_______________________________________________
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