crontab audio alert just before the hour (Debian 13)

EricRP

Member
Joined
Feb 23, 2021
Messages
31
Reaction score
16
Credits
294
I was trying to get my system to give a audio alert (BTW: it is a Morse code letter) just before the hour using the following line
59 * * * * cvlc --play-and-exit /home/name/Music/B_morse_code.mp3

At first the crontab line was different and as I kept changing the minutes number, so it should work within a couple of minutes, but found it never worked
So then I put the line into a command terminal and it never worked either, so eventually got line changed to the following cvlc --play-and-exit /home/name/Music/B_morse_code.mp3 works from the command terminal.

I try a few options but nothing works from the crontab file like
sudo cvlc --play-and-exit /home/name/Music/B_morse_code.mp3

This is what I get when I run it in the command terminal
name@raspberrypi:~ $ cvlc --play-and-exit /home/name/Music/B_morse_code.mp3
VLC media player 3.0.23 Vetinari (revision 3.0.23-2-0-g79128878dd)
[00005555a61d6040] dummy interface: using the dummy interface module...
[00005555a6187ab0] main playlist: end of playlist, exiting
 


Just so you're aware of it, using a variety of colors is going to make your post more difficult to read. We have a few styles for he forum, and the differences can make your colored text more difficult to read.

We have other formatting, such as code goes here. It is in YOUR best interest to use that.

Also, it's a bad idea to use blue. Blue should be a restricted color because it is immediately seen as a link. Links are blue, almost always. This convention even now exists outside of HTML and is in some word processing suites.

If your text is more easily read, it'll attract more viewers and trigger more replies. So, it's in your best interest to use formatting instead of text colors. You absolutely can use colors. You just probably shouldn't.
 
well I am sorry I got out of bed, now it looks like I have a answer to my problem and I am yet to reply to say it works or does not work
 
I was trying to get my system to give a audio alert (BTW: it is a Morse code letter) just before the hour using the following line
59 * * * * cvlc --play-and-exit /home/name/Music/B_morse_code.mp3

At first the crontab line was different and as I kept changing the minutes number, so it should work within a couple of minutes, but found it never worked
So then I put the line into a command terminal and it never worked either, so eventually got line changed to the following cvlc --play-and-exit /home/name/Music/B_morse_code.mp3 works from the command terminal.

I try a few options but nothing works from the crontab file like
sudo cvlc --play-and-exit /home/name/Music/B_morse_code.mp3

This is what I get when I run it in the command terminal
name@raspberrypi:~ $ cvlc --play-and-exit /home/name/Music/B_morse_code.mp3
VLC media player 3.0.23 Vetinari (revision 3.0.23-2-0-g79128878dd)
[00005555a61d6040] dummy interface: using the dummy interface module...
[00005555a6187ab0] main playlist: end of playlist, exiting
The following are the things that have helped me in the past to get cron jobs up. Maybe be useful for you.

To get cron to run a command, it needs to be able to be run as an independent command from the command line. If that's successful, then it can be placed in a cron file from the crontab -e facility.

When the cron job doesn't run, despite running successfully as an independent command on the command line in the first place, then there's a few things that can be tried. If it works, then the following may help.

The main approach is to include a PATH variable in the cron file which includes the path of the command, so if the command is in /home/name/Music/ (as shown in post #1), then that directory should be included in the path, perhaps something like:
Code:
PATH=/home/name/Music:/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin
That is supposed to have cron use that path to find the executable.

Another addition to the cron file which may help is telling cron the shell to use with the code:
Code:
SHELL=/bin/bash

Another possibly helpful element is to have bash explicitly run the executable with code like:
Code:
59 **** bash -c <full-path-to-command>
This is probably best configured with the PATH variable in place as well.

If none of those help, you could write a systemd file and systemd timer file, and that will almost certainly be successful with the correct syntax. On systemd installations, that's never failed here.
 
Last edited:


Follow Linux.org

Staff online

Members online


Top