Audio playback at a certain time (cron)

how can I play an audio file at a certain time. on the nokia n900 it was like this (crontab - beep at the beginning of every hour):
0 7-22 * * * mplayer /home/user/beep.wav

You can try ‘paplay /home/user/beep.wav’

1 Like

As for cron, while there are cron daemons available, you can use system timers to fire something at a certain time.

Of course, it’s more complex and nedlessly convoluted because it’s systemd, but you don’t need to install any thirt party software to do it.

The quick, non-reboot-surviving way to do it would be

$ systemd-run --user --on-calendar 'hourly' /bin/sh -c "/usr/bin/paplay /home/user/beep.wav"

If you’re satisifed, you can save the resulting unit files like so:

$ systemctl --user cat run-<UUID>.timer | grep -v ^# > ~/.config/systemd/user/hourly-bing.timer
$ systemctl --user cat run-<UUID>.service | grep -v ^# > ~/.config/systemd/user/hourly-bing.service

thank you all!
0 7-22 * * * / usr/bin/paplay/home/user/beep.wav
is working. however, I had to install cronie to write the script. it was necessary to set up to work only during the daytime, so the option with the service was not quite satisfied

You can do cron-like intervals with systemd as well, using the OnCalendar setting, but if its working fine with cron why bother. :wink:

thanks for the tip. until today, I have only used cron, it turns out that systemd is a more advanced system :slight_smile:
I will view information on it