Dear kind Fedora users,
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 # [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.
# [olivares@fedora Downloads]$ sudo systemctl list-timers [sudo] password for olivares: NEXT LEFT LAST PASSED UN> Tue 2022-04-05 15:13:39 CDT 1min 46s left n/a n/a sy> Tue 2022-04-05 15:38:11 CDT 26min left n/a n/a dn> Wed 2022-04-06 00:00:00 CDT 8h left Tue 2022-04-05 05:34:07 CDT 9h ago lo> Wed 2022-04-06 00:00:00 CDT 8h left Tue 2022-04-05 05:34:07 CDT 9h ago un> Wed 2022-04-06 00:34:55 CDT 9h left Tue 2022-04-05 05:34:07 CDT 9h ago pl> Sun 2022-04-10 01:00:00 CDT 4 days left Tue 2022-04-05 05:34:07 CDT 9h ago ra> Mon 2022-04-11 00:20:16 CDT 5 days left Tue 2022-04-05 05:34:07 CDT 9h ago fs>
7 timers listed. Pass --all to see loaded but inactive timers, too. #
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. I want to test it out. Thank you in advance
Regards,
Antonio Sent from ProtonMail, encrypted email based in Switzerland.
On 5 Apr 2022, at 21:19, olivares33561 via users users@lists.fedoraproject.org wrote:
Dear kind Fedora users,
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 # [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.
# [olivares@fedora Downloads]$ sudo systemctl list-timers [sudo] password for olivares: NEXT LEFT LAST PASSED UN> Tue 2022-04-05 15:13:39 CDT 1min 46s left n/a n/a sy> Tue 2022-04-05 15:38:11 CDT 26min left n/a n/a dn> Wed 2022-04-06 00:00:00 CDT 8h left Tue 2022-04-05 05:34:07 CDT 9h ago lo> Wed 2022-04-06 00:00:00 CDT 8h left Tue 2022-04-05 05:34:07 CDT 9h ago un> Wed 2022-04-06 00:34:55 CDT 9h left Tue 2022-04-05 05:34:07 CDT 9h ago pl> Sun 2022-04-10 01:00:00 CDT 4 days left Tue 2022-04-05 05:34:07 CDT 9h ago ra> Mon 2022-04-11 00:20:16 CDT 5 days left Tue 2022-04-05 05:34:07 CDT 9h ago fs>
7 timers listed. Pass --all to see loaded but inactive timers, too. #
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. I want to test it out. Thank you in advance
Why not try it out? What is stopping you?
The only thing I would add to you reading list if the man page for systemd.timer
I would start with a timer service that uses /bin/echo that you can use to see that the timer service runs when you expect.
Barry
Regards,
Antonio Sent from ProtonMail, encrypted email based in Switzerland. _______________________________________________ users mailing list -- users@lists.fedoraproject.org To unsubscribe send an email to users-leave@lists.fedoraproject.org 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@lists.fedoraproject.org Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
On Tue Apr05'22 10:02:35PM, Barry wrote:
From: Barry barry@barrys-emacs.org Date: Tue, 5 Apr 2022 22:02:35 +0100 To: olivares33561 olivares33561@protonmail.com, Community support for Fedora users users@lists.fedoraproject.org Reply-To: Community support for Fedora users users@lists.fedoraproject.org Subject: Re: convert crontab jobs to systemd timers
On 5 Apr 2022, at 21:19, olivares33561 via users users@lists.fedoraproject.org wrote:
Dear kind Fedora users,
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 # [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.
# [olivares@fedora Downloads]$ sudo systemctl list-timers [sudo] password for olivares: NEXT LEFT LAST PASSED UN> Tue 2022-04-05 15:13:39 CDT 1min 46s left n/a n/a sy> Tue 2022-04-05 15:38:11 CDT 26min left n/a n/a dn> Wed 2022-04-06 00:00:00 CDT 8h left Tue 2022-04-05 05:34:07 CDT 9h ago lo> Wed 2022-04-06 00:00:00 CDT 8h left Tue 2022-04-05 05:34:07 CDT 9h ago un> Wed 2022-04-06 00:34:55 CDT 9h left Tue 2022-04-05 05:34:07 CDT 9h ago pl> Sun 2022-04-10 01:00:00 CDT 4 days left Tue 2022-04-05 05:34:07 CDT 9h ago ra> Mon 2022-04-11 00:20:16 CDT 5 days left Tue 2022-04-05 05:34:07 CDT 9h ago fs>
7 timers listed. Pass --all to see loaded but inactive timers, too. #
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. I want to test it out. Thank you in advance
Why not try it out? What is stopping you?
The only thing I would add to you reading list if the man page for systemd.timer
I would start with a timer service that uses /bin/echo that you can use to see that the timer service runs when you expect.
Barry
So sorry to suddenly wake up on this thread, but is cron going away. I use it all the time, hourly for backups and nightly for updates.
Many thanks, Ranjan
Sent from ProtonMail, encrypted email based in Switzerland.
------- Original Message ------- On Tuesday, April 5th, 2022 at 6:43 PM, Ranjan Maitra mlmaitra@gmx.com wrote:
On Tue Apr05'22 10:02:35PM, Barry wrote:
From: Barry barry@barrys-emacs.org Date: Tue, 5 Apr 2022 22:02:35 +0100 To: olivares33561 olivares33561@protonmail.com, Community support for Fedora users users@lists.fedoraproject.org Reply-To: Community support for Fedora users users@lists.fedoraproject.org Subject: Re: convert crontab jobs to systemd timers
On 5 Apr 2022, at 21:19, olivares33561 via users users@lists.fedoraproject.org wrote:
Dear kind Fedora users,
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 # [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.
# [olivares@fedora Downloads]$ sudo systemctl list-timers [sudo] password for olivares: NEXT LEFT LAST PASSED UN> Tue 2022-04-05 15:13:39 CDT 1min 46s left n/a n/a sy> Tue 2022-04-05 15:38:11 CDT 26min left n/a n/a dn> Wed 2022-04-06 00:00:00 CDT 8h left Tue 2022-04-05 05:34:07 CDT 9h ago lo> Wed 2022-04-06 00:00:00 CDT 8h left Tue 2022-04-05 05:34:07 CDT 9h ago un> Wed 2022-04-06 00:34:55 CDT 9h left Tue 2022-04-05 05:34:07 CDT 9h ago pl> Sun 2022-04-10 01:00:00 CDT 4 days left Tue 2022-04-05 05:34:07 CDT 9h ago ra> Mon 2022-04-11 00:20:16 CDT 5 days left Tue 2022-04-05 05:34:07 CDT 9h ago fs>
7 timers listed. Pass --all to see loaded but inactive timers, too. #
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. I want to test it out. Thank you in advance
Why not try it out? What is stopping you?
The only thing I would add to you reading list if the man page for systemd.timer
I would start with a timer service that uses /bin/echo that you can use to see that the timer service runs when you expect.
Barry
So sorry to suddenly wake up on this thread, but is cron going away. I use it all the time, hourly for backups and nightly for updates.
Many thanks, Ranjan
I do not know the answer to that question, but I wanted to find out if there are scripts that can help convert a crontab file to a systemd-timer run based. Many people are recommending it. I am used to using crontab, but running Fedora 36(Beta* I know not part of this list, but I had to install anacron to get it working),. In previous versions of Fedora I did not have to do this. So it may*, maynot* survive the future.
In case someone can help, I setup my crontab with the following:
[olivares@fedora ~]$ cat ~/.dalarmsetup2.sh #!/bin/sh # # This script sets up to find music and sets up a player and plays music at a certain time # # create file to find music and setup crontab accordingly FIND=$(echo `which find`) SORT=$(echo `which sort`) XTERM=$(echo `which xterm`) MPLAYER=$(echo `which mplayer`) SLEEP=$(echo `which sleep`) KILL=$(echo `which kill`) XSET=$(echo `which xset`) echo "#!/bin/sh " >> ~/.fndmus echo "# " >> ~/.fndmus echo "# find the music & create playlist" >> ~/.fndmus echo "# " >> ~/.fndmus echo "# find the music check ~/ /media/disk where music is stored :)" >> ~/.fndmus echo "$FIND ~/ -iname ""*.mp3"" -o -iname ""*.og*"" -o -iname ""*.m4a""-o -iname ""*.wma"" -o -iname "*.ra"> ~/.playlist-all " >> ~/.fndmus echo "# sort the playlist " >> ~/.fndmus echo "$SORT ~/.playlist-all> ~/.playlist " >> ~/.fndmus chmod +x ~/.fndmus # setup crontab to play music #set -ue tmp=/tmp/crontab$$ crontab -l >"$tmp" echo "# min hour day-of-month month day-of-week command" >> "$tmp" echo "# 0-59 0-23 1-31 1-12 0-6 0=sun 1=mon " >> "$tmp" echo "#50 04 * * 1-5 ~/.xalarm >/dev/null 2>&1" >>"$tmp" echo "#50 04 * * 0,6 ~/.salarm >/dev/null 2>&1" >>"$tmp" echo "#59 09 * * 0,6 ~/.salarm >/dev/null 2>&1" >>"$tmp" echo "#00 07 * * 1-5 ~/.xalarm >/dev/null 2>&1" >>"$tmp" echo "42 08 * * 1-5 ~/.dalarm >/dev/null 2>&1" >>"$tmp" echo "52 09 * * 1-5 ~/.dalarm >/dev/null 2>&1" >>"$tmp" echo "40 10 * * 1-5 ~/.dalarm >/dev/null 2>&1" >>"$tmp" echo "28 11 * * 1-5 ~/.dalarm >/dev/null 2>&1" >>"$tmp" echo "16 12 * * 1-5 ~/.dalarm >/dev/null 2>&1" >>"$tmp" echo "57 12 * * 1-5 ~/.dalarm >/dev/null 2>&1" >>"$tmp" echo "40 14 * * 1-5 ~/.dalarm >/dev/null 2>&1" >>"$tmp" echo "28 15 * * 1-5 ~/.dalarm >/dev/null 2>&1" >>"$tmp" echo "17 16 * * 1-5 ~/.dalarm >/dev/null 2>&1 " >>"$tmp" echo "#30 16 * * 1-5 ~/.lalarm > /dev/null 2>&1" >> "$tmp" echo "25 16 * * 1-5 sudo systemctl poweroff >/dev/null 2>&1" >>"$tmp" crontab "$tmp" rm "$tmp" # setup Mplayer to play with xterm echo "#!/bin/sh " >> ~/.xalarm echo "# " >> ~/.xalarm echo "# save as ~/.xalarm " >> ~/.xalarm echo " " >> ~/.xalarm echo "export DISPLAY=:0" >> ~/.xalarm echo "$XSET dpms force on;" >> ~/.xalarm echo "$XSET -dpms;" >> ~/.xalarm echo " " >> ~/.xalarm echo "$XTERM -display :0 -bg black -fg white \" >> ~/.xalarm echo "-e $MPLAYER -really-quiet -shuffle -playlist ~/.playlist & PID=$!" >> ~/.xalarm echo "$SLEEP 1680" >> ~/.xalarm echo "$KILL $PID" >> ~/.xalarm echo " " >> ~/.xalarm echo "$XSET +dpms;" >> ~/.xalarm echo "$XSET dpms force off;" >> ~/.xalarm chmod +x ~/.xalarm # run the script mean to find music and create playlist ~/.fndmus cp ~/.xalarm ~/.lalarm cp ~/.xalarm ~/.salarm cp ~/.xalarm ~/.dalarm sed -i 's|1680|14400|g' ~/.lalarm sed -i 's|1680|600|g' ~/.salarm sed -i 's|1680|360|g' ~/.dalarm
It calls on several programs and it sets it up and works automagically :) I just want to have something in case this functionality goes away and try it out and hope it works the same. I had to add code to enable the monitor(since I am using hdmi), the screen needs to wake up and had to install xset. If anyone can share code/script to convert the above crontab to a systemd-timer unit It would be awesome.
Links [1] : https://fedoraproject.org/wiki/Features/SystemdCalendarTimers [2] : https://wiki.archlinux.org/title/Systemd/Timers
Thanks & Best Regards,
Antonio
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
On 6 Apr 2022, at 00:43, Ranjan Maitra mlmaitra@gmx.com wrote:
So sorry to suddenly wake up on this thread, but is cron going away. I use it all the time, hourly for backups and nightly for updates.
Many thanks, Ranjan
cron is not going away, but it's got a cryptic syntax and is, in my experience, easy to make mistakes with. Where as the systemd timers and services are easier to understand and have do exactly what you want, at the cost of being more verbose, but explicit syntax.
Barry
On Apr 5, 2022, at 16:19, olivares33561 via users users@lists.fedoraproject.org wrote:
[olivares@fedora Downloads]$ crontab -l […] [olivares@fedora Downloads]$ sudo systemctl list-timers
I noticed you put your crontab entries in your user crontab, but later looked at system timers. You will want to either use system timers with your User defined in the service, or use your user systemd to run those timers, using “systemctl --user”.
The user systemd only runs during an active login session unless you set it up otherwise, so take that into consideration.
-- Jonathan Billings
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.
Sent from ProtonMail, encrypted email based in Switzerland.
------- Original Message ------- On Wednesday, April 6th, 2022 at 8:09 PM, Tim via users users@lists.fedoraproject.org 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 [olivares@fedora ~]$ cat /etc/systemd/system/poweroff. poweroff.service poweroff.timer [olivares@fedora ~]$ cat /etc/systemd/system/poweroff.timer # /etc/systemd/system/poweroff.timer [Unit] Description=Poweroff maschine at 4:20 PM Mo-Fri
[Timer] OnCalendar=Mon..Fri *-*-* 16:20:00 Persistent=true
[Install] WantedBy=timers.target [olivares@fedora ~]$
and I test it and it did not work. (tested shutdown at 8:20 AM, have changed it to 16:20:00 which is 4:20 pm) What do I need to add? I had /usr/sbin/poweroff in a crontab, and it too failed. I get the following messages for attempting to debug.
[olivares@fedora ~]$ systemctl --user status ● fedora State: running Jobs: 0 queued Failed: 0 units Since: Thu 2022-04-07 10:26:09 CDT; 3h 13min ago CGroup: /user.slice/user-1000.slice/user@1000.service ├─app.slice │ ├─app-cgroupify.slice │ │ ├─cgroupify@app-gnome-chromium\x2dbrowser-2471.scope.service │ │ │ └─2480 /usr/libexec/cgroupify "app-gnome-chromium\x2dbrowser-… │ │ └─cgroupify@app-gnome-firefox-1948.scope.service │ │ └─1952 /usr/libexec/cgroupify app-gnome-firefox-1948.scope │ ├─app-gnome-TiLEM-1478.scope │ │ └─1478 /usr/bin/tilem2 │ ├─app-gnome-chromium\x2dbrowser-2471.scope │ │ ├─2471 │ │ │ └─2471 "/usr/lib64/chromium-browser/chromium-browser --ozone-p… │ │ ├─2484 │ │ │ └─2484 /usr/lib64/chromium-browser/chrome_crashpad_handler --m… │ │ ├─2486 │ │ │ └─2486 /usr/lib64/chromium-browser/chrome_crashpad_handler --n… │ │ ├─2490 │ │ │ └─2490 "/usr/lib64/chromium-browser/chromium-browser --type=zy… │ │ ├─2491 │ │ │ └─2491 "/usr/lib64/chromium-browser/chromium-browser --type=zy… │ │ ├─2493 │ │ │ └─2493 "/usr/lib64/chromium-browser/chromium-browser --type=zy… │ │ ├─2522 │ │ │ └─2522 "/usr/lib64/chromium-browser/chromium-browser --type=gp… │ │ ├─2523 │ │ │ └─2523 "/usr/lib64/chromium-browser/chromium-browser --type=ut… │ │ ├─2564 │ │ │ └─2564 "/usr/lib64/chromium-browser/chromium-browser --type=ut… │ │ ├─2596 │ │ │ └─2596 "/usr/lib64/chromium-browser/chromium-browser --type=re… │ │ ├─2750 │ │ │ └─2750 "/usr/lib64/chromium-browser/chromium-browser --type=re… │ │ ├─2777 │ │ │ └─2777 "/usr/lib64/chromium-browser/chromium-browser --type=ut… │ │ ├─2864 │ │ │ └─2864 "/usr/lib64/chromium-browser/chromium-browser --type=re… │ │ ├─2948 │ │ │ └─2948 "/usr/lib64/chromium-browser/chromium-browser --type=re… │ │ ├─2988 │ │ │ └─2988 "/usr/lib64/chromium-browser/chromium-browser --type=re… │ │ ├─6008 │ │ │ └─6008 "/usr/lib64/chromium-browser/chromium-browser --type=re… │ │ └─6044 │ │ └─6044 "/usr/lib64/chromium-browser/chromium-browser --type=re… │ ├─app-gnome-firefox-1948.scope │ │ ├─1948 │ │ │ └─1948 /usr/lib64/firefox/firefox │ │ ├─2064 │ │ │ └─2064 /usr/lib64/firefox/firefox -contentproc -parentBuildID … │ │ ├─2095 │ │ │ └─2095 /usr/lib64/firefox/firefox -contentproc -childID 1 -isF… │ │ ├─2157 │ │ │ └─2157 /usr/lib64/firefox/firefox -contentproc -childID 2 -isF… │ │ ├─2212 │ │ │ └─2212 /usr/lib64/firefox/firefox -contentproc -childID 3 -isF… │ │ ├─22533 │ │ │ └─22533 /usr/lib64/firefox/firefox -contentproc -childID 58 -i… │ │ ├─2285 │ │ │ └─2285 /usr/lib64/firefox/firefox -contentproc -childID 4 -isF… │ │ ├─2289 │ │ │ └─2289 /usr/lib64/firefox/firefox -contentproc -childID 5 -isF… │ │ ├─23923 │ │ │ └─23923 /usr/lib64/firefox/firefox -contentproc -childID 73 -i… │ │ ├─24245 │ │ │ └─24245 /usr/lib64/firefox/firefox -contentproc -childID 78 -i… │ │ ├─24413 │ │ │ └─24413 /usr/lib64/firefox/firefox -contentproc -childID 80 -i… │ │ ├─24416 │ │ │ └─24416 /usr/lib64/firefox/firefox -contentproc -childID 81 -i… │ │ ├─24505 │ │ │ └─24505 /usr/lib64/firefox/firefox -contentproc -childID 82 -i… │ │ ├─24508 │ │ │ └─24508 /usr/lib64/firefox/firefox -contentproc -childID 83 -i… │ │ └─3280 │ │ └─3280 /usr/lib64/firefox/firefox -contentproc -parentBuildID … │ ├─app-gnome-gkrellm-1469.scope │ │ └─1469 /usr/bin/gkrellm │ ├─app-gnome-org.gnome.Evolution\x2dalarm\x2dnotify-1473.scope │ │ └─1473 /usr/libexec/evolution-data-server/evolution-alarm-notify │ ├─app-gnome-org.gnome.SettingsDaemon.DiskUtilityNotify-1461.scope │ │ └─1461 /usr/libexec/gsd-disk-utility-notify │ ├─app-gnome-org.gnome.Software-1481.scope │ │ └─1481 /usr/bin/gnome-software --gapplication-service │ ├─app-gnome-x48-1456.scope │ │ └─1456 /usr/local/bin/x48 │ ├─app-gnome\x2dsession\x2dmanager.slice │ │ └─gnome-session-manager@gnome.service │ │ └─1171 /usr/libexec/gnome-session-binary --systemd-service --s… │ ├─app-org.gnome.Terminal.slice │ │ ├─gnome-terminal-server.service │ │ │ └─7594 /usr/libexec/gnome-terminal-server │ │ └─vte-spawn-265a1443-1c4b-409c-be79-966ca097e10d.scope │ │ ├─ 7612 bash │ │ └─24643 systemctl --user status │ ├─dbus-:1.2-org.freedesktop.portal.IBus@0.service │ │ └─1597 /usr/libexec/ibus-portal │ ├─dbus-:1.2-org.freedesktop.problems.applet@0.service │ │ └─1536 /usr/bin/abrt-applet --gapplication-service │ ├─dbus-:1.2-org.gnome.Identity@0.service │ │ └─1363 /usr/libexec/goa-identity-service │ ├─dbus-:1.2-org.gnome.OnlineAccounts@0.service │ │ └─1293 /usr/libexec/goa-daemon │ ├─dbus-:1.2-org.gnome.ScreenSaver@0.service │ │ └─1553 /usr/bin/gjs /usr/share/gnome-shell/org.gnome.ScreenSaver │ ├─dbus-:1.2-org.gnome.Shell.CalendarServer@0.service │ │ └─1279 /usr/libexec/gnome-shell-calendar-server │ ├─dbus-:1.2-org.gnome.Shell.Notifications@0.service │ │ └─1381 /usr/bin/gjs /usr/share/gnome-shell/org.gnome.Shell.Notif… │ ├─dbus-:1.25-org.a11y.atspi.Registry@0.service │ │ └─1382 /usr/libexec/at-spi2-registryd --use-gnome-session │ ├─dconf.service │ │ └─1314 /usr/libexec/dconf-service │ ├─evolution-addressbook-factory.service │ │ └─1338 /usr/libexec/evolution-addressbook-factory │ ├─evolution-calendar-factory.service │ │ └─1299 /usr/libexec/evolution-calendar-factory │ ├─evolution-source-registry.service │ │ └─1288 /usr/libexec/evolution-source-registry │ ├─gnome-session-monitor.service │ │ └─1168 /usr/libexec/gnome-session-ctl --monitor │ ├─xdg-desktop-portal-gnome.service │ │ └─1706 /usr/libexec/xdg-desktop-portal-gnome │ ├─xdg-desktop-portal-gtk.service │ │ └─1801 /usr/libexec/xdg-desktop-portal-gtk │ └─xdg-permission-store.service │ └─1278 /usr/libexec/xdg-permission-store ├─init.scope │ ├─1102 /usr/lib/systemd/systemd --user │ └─1104 "(sd-pam)" ├─session.slice │ ├─at-spi-dbus-bus.service │ │ ├─1262 /usr/libexec/at-spi-bus-launcher │ │ ├─1267 /usr/bin/dbus-broker-launch --config-file=/usr/share/defa… │ │ └─1268 dbus-broker --log 4 --controller 9 --machine-id 146af9411… │ ├─dbus-broker.service │ │ ├─1120 /usr/bin/dbus-broker-launch --scope user │ │ └─1121 dbus-broker --log 4 --controller 9 --machine-id 146af9411… │ ├─gvfs-afc-volume-monitor.service │ │ └─1365 /usr/libexec/gvfs-afc-volume-monitor │ ├─gvfs-daemon.service │ │ ├─1174 /usr/libexec/gvfsd │ │ ├─1204 /usr/libexec/gvfsd-fuse /run/user/1000/gvfs -f │ │ ├─3021 /usr/libexec/gvfsd-trash --spawner :1.16 /org/gtk/gvfs/ex… │ │ ├─3043 /usr/libexec/gvfsd-network --spawner :1.16 /org/gtk/gvfs/… │ │ └─3073 /usr/libexec/gvfsd-dnssd --spawner :1.16 /org/gtk/gvfs/ex… │ ├─gvfs-goa-volume-monitor.service │ │ └─1343 /usr/libexec/gvfs-goa-volume-monitor │ ├─gvfs-gphoto2-volume-monitor.service │ │ └─1332 /usr/libexec/gvfs-gphoto2-volume-monitor │ ├─gvfs-metadata.service │ │ └─2928 /usr/libexec/gvfsd-metadata │ ├─gvfs-mtp-volume-monitor.service │ │ └─1326 /usr/libexec/gvfs-mtp-volume-monitor │ ├─gvfs-udisks2-volume-monitor.service │ │ └─1321 /usr/libexec/gvfs-udisks2-volume-monitor │ ├─org.freedesktop.IBus.session.GNOME.service │ │ ├─1399 /usr/bin/ibus-daemon --panel disable │ │ ├─1590 /usr/libexec/ibus-dconf │ │ ├─1591 /usr/libexec/ibus-extension-gtk3 │ │ └─1710 /usr/libexec/ibus-engine-simple │ ├─org.gnome.SettingsDaemon.A11ySettings.service │ │ └─1401 /usr/libexec/gsd-a11y-settings │ ├─org.gnome.SettingsDaemon.Color.service │ │ └─1405 /usr/libexec/gsd-color │ ├─org.gnome.SettingsDaemon.Datetime.service │ │ └─1407 /usr/libexec/gsd-datetime │ ├─org.gnome.SettingsDaemon.Housekeeping.service │ │ └─1408 /usr/libexec/gsd-housekeeping │ ├─org.gnome.SettingsDaemon.Keyboard.service │ │ └─1411 /usr/libexec/gsd-keyboard │ ├─org.gnome.SettingsDaemon.MediaKeys.service │ │ └─1413 /usr/libexec/gsd-media-keys │ ├─org.gnome.SettingsDaemon.Power.service │ │ └─1416 /usr/libexec/gsd-power │ ├─org.gnome.SettingsDaemon.PrintNotifications.service │ │ ├─1425 /usr/libexec/gsd-print-notifications │ │ └─1680 /usr/libexec/gsd-printer │ ├─org.gnome.SettingsDaemon.Rfkill.service │ │ └─1427 /usr/libexec/gsd-rfkill │ ├─org.gnome.SettingsDaemon.ScreensaverProxy.service │ │ └─1430 /usr/libexec/gsd-screensaver-proxy │ ├─org.gnome.SettingsDaemon.Sharing.service │ │ └─1434 /usr/libexec/gsd-sharing │ ├─org.gnome.SettingsDaemon.Smartcard.service │ │ └─1435 /usr/libexec/gsd-smartcard │ ├─org.gnome.SettingsDaemon.Sound.service │ │ └─1436 /usr/libexec/gsd-sound │ ├─org.gnome.SettingsDaemon.UsbProtection.service │ │ └─1437 /usr/libexec/gsd-usb-protection │ ├─org.gnome.SettingsDaemon.Wacom.service │ │ └─1438 /usr/libexec/gsd-wacom │ ├─org.gnome.SettingsDaemon.XSettings.service │ │ ├─1773 /usr/libexec/gsd-xsettings │ │ └─1802 /usr/libexec/ibus-x11 │ ├─org.gnome.Shell@wayland.service │ │ ├─1200 /usr/bin/gnome-shell │ │ └─1626 /usr/bin/Xwayland :0 -rootless -noreset -accessx -core -a… │ ├─pipewire-pulse.service │ │ └─1294 /usr/bin/pipewire-pulse │ ├─pipewire.service │ │ └─1214 /usr/bin/pipewire │ ├─wireplumber.service │ │ └─1215 /usr/bin/wireplumber │ ├─xdg-desktop-portal.service │ │ └─1692 /usr/libexec/xdg-desktop-portal │ └─xdg-document-portal.service │ ├─1698 /usr/libexec/xdg-document-portal │ └─1702 fusermount -o rw,nosuid,nodev,fsname=portal,auto_unmount,… └─uresourced.service └─1169 /usr/libexec/uresourced --user [olivares@fedora ~]$ systemctl --user list-unit-files UNIT FILE STATE VENDOR PRESET app-glib-vmware\x2duser-1454.scope transient - app-gnome-chromium\x2dbrowser-2471.scope transient - app-gnome-firefox-1948.scope transient - app-gnome-gkrellm-1469.scope transient - app-gnome-org.gnome.Evolution\x2dalarm\x2dnotify-1473.s… transient - app-gnome-org.gnome.SettingsDaemon.DiskUtilityNotify-14… transient - app-gnome-org.gnome.Software-1481.scope transient - app-gnome-TiLEM-1478.scope transient - app-gnome-x48-1456.scope transient - vte-spawn-265a1443-1c4b-409c-be79-966ca097e10d.scope transient - app-geoclue\x2ddemo\x2dagent@autostart.service generated - app-gkrellm@autostart.service generated - app-gnome\x2dinitial\x2dsetup\x2dfirst\x2dlogin@autosta… generated - app-gnome\x2dshell\x2doverrides\x2dmigration@autostart.… generated - app-orca\x2dautostart@autostart.service generated - app-org.freedesktop.problems.applet@autostart.service generated - app-org.gnome.Evolution\x2dalarm\x2dnotify@autostart.se… generated - app-org.gnome.SettingsDaemon.DiskUtilityNotify@autostar… generated - app-org.gnome.Software@autostart.service generated - app-TiLEM@autostart.service generated - app-user\x2ddirs\x2dupdate\x2dgtk@autostart.service generated - app-vboxclient@autostart.service generated - app-vmware\x2duser@autostart.service generated - app-x48@autostart.service generated - at-spi-dbus-bus.service static - cgroupify@.service static - colord-session.service static - dbus-:1.2-org.freedesktop.portal.IBus@0.service transient - dbus-:1.2-org.freedesktop.problems.applet@0.service transient - dbus-:1.2-org.gnome.Identity@0.service transient - dbus-:1.2-org.gnome.OnlineAccounts@0.service transient - dbus-:1.2-org.gnome.ScreenSaver@0.service transient - dbus-:1.2-org.gnome.Shell.CalendarServer@0.service transient - dbus-:1.2-org.gnome.Shell.Notifications@0.service transient - dbus-:1.25-org.a11y.atspi.Registry@0.service transient - dbus-broker.service enabled enabled dbus-daemon.service disabled disabled dbus.service alias - dconf.service static - dirmngr.service static - evolution-addressbook-factory.service static - evolution-calendar-factory.service static - evolution-source-registry.service static - evolution-user-prompter.service static - flatpak-oci-authenticator.service static - flatpak-portal.service static - flatpak-session-helper.service static - gamemoded.service disabled disabled gcr-ssh-agent.service disabled disabled glib-pacrunner.service static - gnome-initial-setup-copy-worker.service static - gnome-initial-setup-first-login.service static - gnome-remote-desktop.service static - gnome-session-failed.service static - gnome-session-manager@.service static - gnome-session-monitor.service static - gnome-session-restart-dbus.service static - gnome-session-signal-init.service static - gnome-terminal-server.service static - gnome-user-share-webdav.service static - gpg-agent.service static - grub-boot-success.service static - gvfs-afc-volume-monitor.service static - gvfs-daemon.service static - gvfs-goa-volume-monitor.service static - gvfs-gphoto2-volume-monitor.service static - gvfs-metadata.service static - gvfs-mtp-volume-monitor.service static - gvfs-udisks2-volume-monitor.service static - org.freedesktop.IBus.session.generic.service static - org.freedesktop.IBus.session.GNOME.service disabled disabled org.gnome.Evince.service static - org.gnome.SettingsDaemon.A11ySettings.service static - org.gnome.SettingsDaemon.Color.service static - org.gnome.SettingsDaemon.Datetime.service static - org.gnome.SettingsDaemon.Housekeeping.service static - org.gnome.SettingsDaemon.Keyboard.service static - org.gnome.SettingsDaemon.MediaKeys.service static - org.gnome.SettingsDaemon.Power.service static - org.gnome.SettingsDaemon.PrintNotifications.service static - org.gnome.SettingsDaemon.Rfkill.service static - org.gnome.SettingsDaemon.ScreensaverProxy.service static - org.gnome.SettingsDaemon.Sharing.service static - org.gnome.SettingsDaemon.Smartcard.service static - org.gnome.SettingsDaemon.Sound.service static - org.gnome.SettingsDaemon.UsbProtection.service static - org.gnome.SettingsDaemon.Wacom.service static - org.gnome.SettingsDaemon.Wwan.service static - org.gnome.SettingsDaemon.XSettings.service static - org.gnome.Shell-disable-extensions.service static - org.gnome.Shell@wayland.service static - org.gnome.Shell@x11.service static - p11-kit-client.service disabled disabled p11-kit-server.service disabled disabled pipewire-pulse.service disabled disabled pipewire-session-manager.service alias - pipewire.service disabled disabled plasma-kglobalaccel.service static - podman-auto-update.service disabled disabled podman-restart.service disabled disabled podman.service disabled disabled rygel.service disabled disabled spice-vdagent.service static - ssh-agent.service static - systemd-exit.service static - systemd-tmpfiles-clean.service static - systemd-tmpfiles-setup.service enabled enabled tracker-extract-3.service disabled disabled tracker-miner-fs-3.service disabled disabled tracker-miner-fs-control-3.service static - tracker-miner-rss-3.service disabled disabled tracker-writeback-3.service static - tracker-xdg-portal-3.service static - uresourced.service static - wireplumber.service enabled enabled wireplumber@.service disabled disabled xdg-desktop-portal-gnome.service static - xdg-desktop-portal-gtk.service static - xdg-desktop-portal.service static - xdg-document-portal.service static - xdg-permission-store.service static - app.slice static - background.slice static - session.slice static - dbus.socket enabled enabled dirmngr.socket disabled disabled gcr-ssh-agent.socket disabled disabled gpg-agent-browser.socket disabled disabled gpg-agent-extra.socket disabled disabled gpg-agent-ssh.socket disabled disabled gpg-agent.socket disabled disabled p11-kit-server.socket disabled disabled pipewire-pulse.socket enabled enabled pipewire.socket enabled enabled podman.socket disabled disabled basic.target static - bluetooth.target static - default.target static - exit.target static - gnome-session-failed.target static - gnome-session-initialized.target static - gnome-session-manager.target static - gnome-session-pre.target static - gnome-session-shutdown.target static - gnome-session-wayland.target static - gnome-session-wayland@.target static - gnome-session-x11-services-ready.target static - gnome-session-x11-services.target static - gnome-session-x11.target static - gnome-session-x11@.target static - gnome-session.target static - gnome-session@.target static - graphical-session-pre.target static - graphical-session.target static - org.gnome.SettingsDaemon.A11ySettings.target static - org.gnome.SettingsDaemon.Color.target static - org.gnome.SettingsDaemon.Datetime.target static - org.gnome.SettingsDaemon.Housekeeping.target static - org.gnome.SettingsDaemon.Keyboard.target static - org.gnome.SettingsDaemon.MediaKeys.target static - org.gnome.SettingsDaemon.Power.target static - org.gnome.SettingsDaemon.PrintNotifications.target static - org.gnome.SettingsDaemon.Rfkill.target static - org.gnome.SettingsDaemon.ScreensaverProxy.target static - org.gnome.SettingsDaemon.Sharing.target static - org.gnome.SettingsDaemon.Smartcard.target static - org.gnome.SettingsDaemon.Sound.target static - org.gnome.SettingsDaemon.UsbProtection.target static - org.gnome.SettingsDaemon.Wacom.target static - org.gnome.SettingsDaemon.Wwan.target static - org.gnome.SettingsDaemon.XSettings.target static - org.gnome.Shell.target static - paths.target static - printer.target static - shutdown.target static - smartcard.target static - sockets.target static - sound.target static - timers.target static - xdg-desktop-autostart.target static - grub-boot-success.timer static - podman-auto-update.timer disabled disabled systemd-tmpfiles-clean.timer enabled enabled
183 unit files listed. [olivares@fedora ~]$ sudo mcedit /etc/systemd/system/poweroff.service [sudo] password for olivares:
[olivares@fedora ~]$ sudo systemctl enable --now 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. Job for poweroff.service failed because the control process exited with error code. See "systemctl status poweroff.service" and "journalctl -xeu poweroff.service" for details. [olivares@fedora ~]$ systemctl status poweroff.service"
^C
[olivares@fedora ~]$ systemctl status poweroff.service × poweroff.service - Poweroff maschine at 16:20 PM Mo-Fri Loaded: loaded (/etc/systemd/system/poweroff.service; static) Active: failed (Result: exit-code) since Thu 2022-04-07 13:42:36 CDT; 39s ago TriggeredBy: ● poweroff.timer Process: 24819 ExecStart=sudo systemctl poweroff (code=exited, status=203/EXEC) Main PID: 24819 (code=exited, status=203/EXEC) CPU: 849us
Apr 07 13:42:36 fedora systemd[1]: Starting poweroff.service - Poweroff mas…i... Apr 07 13:42:36 fedora systemd[24819]: poweroff.service: Failed to locate e…tory Apr 07 13:42:36 fedora systemd[24819]: poweroff.service: Failed at step EXE…tory Apr 07 13:42:36 fedora systemd[1]: poweroff.service: Main process exited, c…EXEC Apr 07 13:42:36 fedora systemd[1]: poweroff.service: Failed with result 'ex…de'. Apr 07 13:42:36 fedora systemd[1]: Failed to start poweroff.service - Power…Fri. Hint: Some lines were ellipsized, use -l to show in full. [olivares@fedora ~]$ systemctl status poweroff.service -l × poweroff.service - Poweroff maschine at 16:20 PM Mo-Fri Loaded: loaded (/etc/systemd/system/poweroff.service; static) Active: failed (Result: exit-code) since Thu 2022-04-07 13:42:36 CDT; 52s ago TriggeredBy: ● poweroff.timer Process: 24819 ExecStart=sudo systemctl poweroff (code=exited, status=203/EXEC) Main PID: 24819 (code=exited, status=203/EXEC) CPU: 849us
Apr 07 13:42:36 fedora systemd[1]: Starting poweroff.service - Poweroff maschine at 16:20 PM Mo-Fri... Apr 07 13:42:36 fedora systemd[24819]: poweroff.service: Failed to locate executable sudo: No such file or directory Apr 07 13:42:36 fedora systemd[24819]: poweroff.service: Failed at step EXEC spawning sudo: No such file or directory Apr 07 13:42:36 fedora systemd[1]: poweroff.service: Main process exited, code=exited, status=203/EXEC Apr 07 13:42:36 fedora systemd[1]: poweroff.service: Failed with result 'exit-code'. Apr 07 13:42:36 fedora systemd[1]: Failed to start poweroff.service - Poweroff maschine at 16:20 PM Mo-Fri. [olivares@fedora ~]$ journalctl -xeu poweroff.service Apr 07 13:42:36 fedora systemd[1]: Starting poweroff.service - Poweroff maschine at 16:20 PM Mo-Fri... ░░ Subject: A start job for unit poweroff.service has begun execution ░░ Defined-By: systemd ░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel ░░ ░░ A start job for unit poweroff.service has begun execution. ░░ ░░ The job identifier is 3636. Apr 07 13:42:36 fedora systemd[24819]: poweroff.service: Failed to locate executable sudo: No such file or directory ░░ Subject: Process sudo could not be executed ░░ Defined-By: systemd ░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel ░░ ░░ The process sudo could not be executed and failed. ░░ ░░ The error number returned by this process is ERRNO. Apr 07 13:42:36 fedora systemd[24819]: poweroff.service: Failed at step EXEC spawning sudo: No such file or directory ░░ Subject: Process sudo could not be executed ░░ Defined-By: systemd ░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel ░░ ░░ The process sudo could not be executed and failed. ░░ ░░ The error number returned by this process is ERRNO. Apr 07 13:42:36 fedora systemd[1]: poweroff.service: Main process exited, code=exited, status=203/EXEC ░░ Subject: Unit process exited ░░ Defined-By: systemd ░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel ░░ ░░ An ExecStart= process belonging to unit poweroff.service has exited. ░░ ░░ The process' exit code is 'exited' and its exit status is 203. Apr 07 13:42:36 fedora systemd[1]: poweroff.service: Failed with result 'exit-code'. ░░ Subject: Unit failed ░░ Defined-By: systemd ░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel ░░ ░░ The unit poweroff.service has entered the 'failed' state with result 'exit-code'. Apr 07 13:42:36 fedora systemd[1]: Failed to start poweroff.service - Poweroff maschine at 16:20 PM Mo-Fri. ░░ Subject: A start job for unit poweroff.service has failed ░░ Defined-By: systemd ░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel ░░ ░░ A start job for unit poweroff.service has finished with a failure. ░░ ░░ The job identifier is 3636 and the job result is failed. [olivares@fedora ~]$
I have read the manuals, but I do need some help. With cron it was much easier to setup, but as cron(*may be depracated/or not available) I want to have the ability to have same functionality as before. I only need .dalarm to work, I do not need .salarm/.xalarm to work as they are commented out on crontab. But I will worry about this later, if I get poweroff service to work, I can proceed to try and find a working solution to the converting to systemd-timer.
TIA & Best Regards,
Antonio
On 4/7/22 11:53, olivares33561 via users wrote:
Sent from ProtonMail, encrypted email based in Switzerland.
------- Original Message ------- On Wednesday, April 6th, 2022 at 8:09 PM, Tim via users users@lists.fedoraproject.org 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 [olivares@fedora ~]$ cat /etc/systemd/system/poweroff. poweroff.service poweroff.timer [olivares@fedora ~]$ cat /etc/systemd/system/poweroff.timer # /etc/systemd/system/poweroff.timer [Unit] Description=Poweroff maschine at 4:20 PM Mo-Fri
[Timer] OnCalendar=Mon..Fri *-*-* 16:20:00 Persistent=true
[Install] WantedBy=timers.target [olivares@fedora ~]$
and I test it and it did not work. (tested shutdown at 8:20 AM, have changed it to 16:20:00 which is 4:20 pm) What do I need to add? I had /usr/sbin/poweroff in a crontab, and it too failed. I get the following messages for attempting to debug.
</snip>
1) systemctl requires a command such as "start" 2) the poweroff.service is calling itself in the ExecStart line. 3) I think sudo shouldn't be necessary since poweroff.service is defined as a system service which already runs as root. 4) there is already a poweroff.target; I don't know if that presents a problem/conflict. 5) you might try "/sbin/poweroff -p" as the ExecStart argument
Looks like you're on the right path. Good luck!
Sent from ProtonMail, encrypted email based in Switzerland.
------- Original Message ------- On Thursday, April 7th, 2022 at 3:04 PM, Mike Wright nobody@nospam.hostisimo.com wrote:
On 4/7/22 11:53, olivares33561 via users wrote:
Sent from ProtonMail, encrypted email based in Switzerland.
------- Original Message ------- On Wednesday, April 6th, 2022 at 8:09 PM, Tim via users users@lists.fedoraproject.org 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 [olivares@fedora ~]$ cat /etc/systemd/system/poweroff. poweroff.service poweroff.timer [olivares@fedora ~]$ cat /etc/systemd/system/poweroff.timer # /etc/systemd/system/poweroff.timer [Unit] Description=Poweroff maschine at 4:20 PM Mo-Fri
[Timer] OnCalendar=Mon..Fri --* 16:20:00 Persistent=true
[Install] WantedBy=timers.target [olivares@fedora ~]$
and I test it and it did not work. (tested shutdown at 8:20 AM, have changed it to 16:20:00 which is 4:20 pm) What do I need to add? I had /usr/sbin/poweroff in a crontab, and it too failed. I get the following messages for attempting to debug.
</snip>
- systemctl requires a command such as "start"
- the poweroff.service is calling itself in the ExecStart line.
- I think sudo shouldn't be necessary since poweroff.service is defined
as a system service which already runs as root. 4) there is already a poweroff.target; I don't know if that presents a problem/conflict. 5) you might try "/sbin/poweroff -p" as the ExecStart argument
Looks like you're on the right path. Good luck! _______________________________________________
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 [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
On 4/7/22 13:22, olivares33561 via users wrote:
Sent from ProtonMail, encrypted email based in Switzerland.
------- Original Message ------- On Thursday, April 7th, 2022 at 3:04 PM, Mike Wright nobody@nospam.hostisimo.com wrote:
On 4/7/22 11:53, olivares33561 via users wrote:
Sent from ProtonMail, encrypted email based in Switzerland.
------- Original Message ------- On Wednesday, April 6th, 2022 at 8:09 PM, Tim via users users@lists.fedoraproject.org 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 [olivares@fedora ~]$ cat /etc/systemd/system/poweroff. poweroff.service poweroff.timer [olivares@fedora ~]$ cat /etc/systemd/system/poweroff.timer # /etc/systemd/system/poweroff.timer [Unit] Description=Poweroff maschine at 4:20 PM Mo-Fri
[Timer] OnCalendar=Mon..Fri --* 16:20:00 Persistent=true
[Install] WantedBy=timers.target [olivares@fedora ~]$
and I test it and it did not work. (tested shutdown at 8:20 AM, have changed it to 16:20:00 which is 4:20 pm) What do I need to add? I had /usr/sbin/poweroff in a crontab, and it too failed. I get the following messages for attempting to debug.
</snip>
- systemctl requires a command such as "start"
- the poweroff.service is calling itself in the ExecStart line.
- I think sudo shouldn't be necessary since poweroff.service is defined
as a system service which already runs as root. 4) there is already a poweroff.target; I don't know if that presents a problem/conflict. 5) you might try "/sbin/poweroff -p" as the ExecStart argument
Looks like you're on the right path. Good luck! _______________________________________________
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
systemctl is still lacking a command. Try systemctl --no-block start poweroff.service
Here is my verrry simple "mute" service and timer:
------- ## mute.service
[Unit] Description="Mute audio"
[Service] Type=oneshot ExecStart=/usr/local/bin/mute
-------- ## mute.timer [Unit] Description="Mute audio"
[Timer] OnCalendar=Mon..Fri *-*-* 06:30:00 OnCalendar=Mon..Fri *-*-* 13:00:00 AccuracySec=1ms Persistent=true OnStartupSec=10ms
[Install] WantedBy=timers.target
-------- I don't think yours would need the AccuracySec and OnStartupSec options
:m
[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 _______________________________________________ users mailing list -- users@lists.fedoraproject.org To unsubscribe send an email to users-leave@lists.fedoraproject.org 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@lists.fedoraproject.org Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
On 7 Apr 2022, at 21:22, olivares33561 via users users@lists.fedoraproject.org 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
/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 _______________________________________________ users mailing list -- users@lists.fedoraproject.org To unsubscribe send an email to users-leave@lists.fedoraproject.org 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@lists.fedoraproject.org Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
Sent from ProtonMail, encrypted email based in Switzerland. ------- Original Message ------- On Friday, April 8th, 2022 at 5:13 AM, Barry Scott barry@barrys-emacs.org wrote:
On 7 Apr 2022, at 21:22, olivares33561 via users users@lists.fedoraproject.org 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
/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]$
Thank you for all who are providing suggestions.
Best Regards,
Antonio
Sent from ProtonMail, encrypted email based in Switzerland. ------- Original Message ------- On Friday, April 8th, 2022 at 7:43 AM, olivares33561 via users users@lists.fedoraproject.org wrote:
Sent from ProtonMail, encrypted email based in Switzerland.
------- Original Message ------- On Friday, April 8th, 2022 at 5:13 AM, Barry Scott barry@barrys-emacs.org wrote:
On 7 Apr 2022, at 21:22, olivares33561 via users users@lists.fedoraproject.org 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
/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]$
Thank you for all who are providing suggestions.
Best Regards,
Antonio
[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
[Install] WantedBy=multi-user.target [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 *-*-* 10:05:00 Persistent=true
[Install] WantedBy=timers.target
[olivares@fedora Downloads]$ systemctl enable --now poweroff.target Failed to enable unit: File /etc/systemd/system/ctrl-alt-del.target already exists and is a symlink to /usr/lib/systemd/system/reboot.target.
Found a relevant thread that almost helped find a working solution.
http://billauer.co.il/blog/2021/01/systemd-money-saver/
It did not work, but it is very close. Maybe I need to change the name and it could work? Any pointers to get it working are appreciated.
Best Regards,
Antonio
On Apr 8, 2022, at 08:43, olivares33561 via users users@lists.fedoraproject.org wrote:
[olivares@fedora user]$ systemctl --user enable poweroff.service
If you are editing files in /etc/systemd/system, then take off the “--user” and use sudo when activating the service. Never use sudo in a systemd Exec line unless you have a really specific need for it.
It will need to be run as the system because only root can activate the poweroff non-interactively.
I’m also not really thrilled with the idea of a systemd service calling systemctl. It seems to me it would make more sense to have the timer directly reference Unit=poweroff.target and forgo the service unit entirely.
-- Jonathan Billings
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@barrys-emacs.org wrote:
On 7 Apr 2022, at 21:22, olivares33561 via users users@lists.fedoraproject.org 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@lists.fedoraproject.org To unsubscribe send an email to users-leave@lists.fedoraproject.org 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@lists.fedoraproject.org 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.
Sent from ProtonMail, encrypted email based in Switzerland. ------- Original Message ------- On Saturday, April 9th, 2022 at 5:46 PM, Mike Wright nobody@nospam.hostisimo.com wrote:
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@barrys-emacs.org wrote:
On 7 Apr 2022, at 21:22, olivares33561 via users users@lists.fedoraproject.org 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@lists.fedoraproject.org To unsubscribe send an email to users-leave@lists.fedoraproject.org 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@lists.fedoraproject.org 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.
I will report back with one that works, but with a caveat. I still need to fix a problem with display. The monitor goes to sleep and I need to wake it up. If it is up, the service and timers created work great. a dalarm service and dalarm.timer :
[olivares@fedora ~]$ cd .config/systemd/user/ [olivares@fedora user]$ ls dalarm.service dalarm.timer default.target.wants timers.target.wants [olivares@fedora user]$ cat dalarm.timer [Unit] Description=Schedule a message every 1 minute RefuseManualStart=no # Allow manual starts RefuseManualStop=no # Allow manual stops
[Timer] #Execute job if it missed a run due to machine being off Persistent=true #Run 120 seconds after boot for the first time #OnBootSec=120 #Run every 1 minute thereafter #OnUnitActiveSec=60 #File describing job to execute #Unit=schedule-test.service # run every day OnCalendar=Mon-Fri *-*-* 08:42:00 OnCalendar=Mon-Fri *-*-* 09:52:00 OnCalendar=Mon-Fri *-*-* 10:40:00 OnCalendar=Mon-Fri *-*-* 11:28:00 OnCalendar=Mon-Fri *-*-* 12:16:00 OnCalendar=Mon-Fri *-*-* 12:57:00 OnCalendar=Mon-Fir *-*-* 14:40:00 OnCalendar=Mon-Fri *-*-* 15:28:00 OnCalendar=Mon-Fri *-*-* 16:17:00
[Install] WantedBy=timers.target [olivares@fedora user]$ cat dalarm.service [Unit] Description=A job to test the systemd scheduler & play music to prepare for next class
[Service] Type=simple ExecStart=/home/olivares/bin/dalarm.sh
[Install] WantedBy=default.target [olivares@fedora user]$ cat ~/bin/dalarm.sh #!/bin/sh # #
export DISPLAY=:0 /usr/bin/xset dpms force on; #/usr/bin/xset -dpms;
/usr/bin/xterm -display :0 -bg black -fg white \ -e /usr/local/bin/mplayer -really-quiet -shuffle -playlist ~/.playlist & PID=$! /usr/bin/sleep 360 /usr/bin/kill $PID
#/usr/bin/xset +dpms; /usr/bin/xset dpms force off; [olivares@fedora user]$ cat ~/bin/dalarm.sh #!/bin/sh # #
export DISPLAY=:0 /usr/bin/xset dpms force on; #/usr/bin/xset -dpms;
/usr/bin/xterm -display :0 -bg black -fg white \ -e /usr/local/bin/mplayer -really-quiet -shuffle -playlist ~/.playlist & PID=$! /usr/bin/sleep 360 /usr/bin/kill $PID
#/usr/bin/xset +dpms; /usr/bin/xset dpms force off;
----------------------------------- The script works well, but I need to wake up the screen which it does not do :( This is why I asked the other question and I had to run the command to see if X11 was running or wayland. It is wayland so the old commands do not work. I have it blank after 2 minutes, and if I am not using the computer the dalarm service does not play the music. Thanks to all who have helped/guided me to find a working solution(conversion to systemd-timer for a crontab entry). The one for shutdown I have removed it because it did not work, maybe because there are already services with the same names? I will turn off machine manually in the meantime. If someone has a solution, I would appreciate it very much. I just need a simple shutdown/poweroff at 4:20 ---> 16:20:00 which is the end of the day and it is (Good place/time to stop the machine)
Best Regards,
Antonio
On 7 Apr 2022, at 19:53, olivares33561 via users users@lists.fedoraproject.org wrote:
Sent from ProtonMail, encrypted email based in Switzerland.
------- Original Message ------- On Wednesday, April 6th, 2022 at 8:09 PM, Tim via users users@lists.fedoraproject.org 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