System:
Pi2B
RPiOS Bookworm (32-bit)
Audio player: mplayer
Set to use PulseAudio
Audio output works from shell script run from commandline. Does not work from crontab. (It used to under a prior RPIOS release, but due to other issues and being unwilling to ask for help for an old release, I updated to Bookworm).
Output while running from commandline:Crontab entry:When the same shell script is run from cron:The shell script is:I really wish newer systems wouldn't break things that have been working for the last eight years. Looking for suggestions on how to fix this...
Update: found a fix. Add:To the crontab.
Where <usernum> is found by rinning:
Pi2B
RPiOS Bookworm (32-bit)
Audio player: mplayer
Set to use PulseAudio
Audio output works from shell script run from commandline. Does not work from crontab. (It used to under a prior RPIOS release, but due to other issues and being unwilling to ask for help for an old release, I updated to Bookworm).
Output while running from commandline:
Code:
MPlayer UNKNOWN-12 (C) 2000-2023 MPlayer Teamdo_connect: could not connect to socketconnect: No such file or directoryFailed to open LIRC support. You will not be able to use your remote control.Playing /home/pi/cdmusic/10Thing/18_track18.wav.Cache fill: 0.00% (0 bytes)libavformat version 59.27.100 (external)Audio only file format detected.Load subtitles in /home/pi/cdmusic/10Thing/==========================================================================Opening audio decoder: [pcm] Uncompressed PCM audio decoderAUDIO: 44100 Hz, 2 ch, s16le, 1411.2 kbit/100.00% (ratio: 176400->176400)Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)==========================================================================AO: [pulse] 44100Hz 2ch s16le (2 bytes per sample)Video: no videoStarting playback...A: 204.9 (03:24.9) of 205.0 (03:25.0) 0.1% 0%Code:
01 21 * * * /home/pi/bin/play /home/pi/cdmusic/10Thing/18_track18.wavCode:
MPlayer UNKNOWN-12 (C) 2000-2023 MPlayer Teamdo_connect: could not connect to socketconnect: No such file or directoryFailed to open LIRC support. You will not be able to use your remote control.Terminal type `unknown' is not defined.Playing /home/pi/cdmusic/10Thing/18_track18.wav.Cache fill: 18.75% (196608 bytes)libavformat version 59.27.100 (external)Audio only file format detected.Load subtitles in /home/pi/cdmusic/10Thing/==========================================================================Opening audio decoder: [pcm] Uncompressed PCM audio decoderAUDIO: 44100 Hz, 2 ch, s16le, 1411.2 kbit/100.00% (ratio: 176400->176400)Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)==========================================================================AO: [pulse] Init failed: Connection refusedFailed to initialize audio driver 'pulse'[AO_ALSA] alsa-lib: pcm_hw.c:1722:(snd_pcm_hw_open) open '/dev/snd/pcmC0D0p' failed (-524): Unknown error 524[AO_ALSA] Playback open error: Unknown error 524Failed to initialize audio driver 'alsa'[AO SDL] Samplerate: 44100Hz Channels: Stereo Format s16le[AO SDL] using aalib audio driver.[AO SDL] Unable to open audio: No available audio deviceFailed to initialize audio driver 'sdl:aalib'Could not open/initialize audio device -> no sound.Audio: no soundVideo: no videoCode:
#!/bin/bashexport PATH=/home/pi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/gamesmplayer -cache 1024 -volume 100 $* >> /home/pi/croncheck 2>&1Update: found a fix. Add:
Code:
XDG_RUNTIME_DIR=/run/user/<usernum>Where <usernum> is found by rinning:
Code:
id -uStatistics: Posted by W. H. Heydt — Mon May 26, 2025 4:07 am