Re: Debian 9 cron = sounds are ok : Debian 11 cron no sound
Roger Price wrote:
> On Sat, 16 Jul 2022, Lee wrote:
>
> > I don't have play, so I tried aplay .. and it works, even if I'm
> > logged out, even if someone else is logged in.
> >
> > ## run the script every minute
> >
> > $ crontab -l | tail -3
> > # m h dom mon dow command
> > * * * * * /home/lee/bin/neener.sh
> >
> > ## which plays a .wav and an .au file
> >
> > $ cat ~/bin/neener.sh
> > #!/bin/sh
> > /usr/bin/aplay -q $HOME/Sounds/Old/NEENER.WAV
> > sleep 0.25
> > /usr/bin/aplay -q $HOME/Sounds/SunOS/busy.au
>
> I get the following error message from aplay:
>
> ALSA lib pcm_dmix.c:1075:(snd_pcm_dmix_open) unable to open slave
> aplay: main:830: audio open error: Device or resource busy
>
> and a different message from play:
>
> ALSA lib pcm_dmix.c:1075:(snd_pcm_dmix_open) unable to open slave
> /usr/bin/play FAIL sox: Sorry, there is no default audio device configured
I'm going to guess that:
- you normally have pulseaudio running
- the commands work when systemd has set up a pulseaudio daemon
for you
- the commands don't work when pulseaudio has control of the
audio system but the cron job does not know how to reach it via
a pulseaudio socket
Perhaps putting pulseaudio --start at the beginning of your
script and pulseaudio --kill at the end will fix this.
-dsr-
Reply to: