0

I have a simple command

play -V4 /folder/file.ogg

on command line it works perfect

on crontab

* * * * * klaus  play -V4 /folder/file.ogg

it gets triggered ( i can see it in syslog) but I can't hear it.

CRON[4827]: (klaus) CMD (play -V4 /folder/file.ogg)

UPDATE

the crontab gave me the following debug output

play DBUG alsa: select_format: trying #2
play DBUG alsa: selecting format 2: S16_LE (Signed 16 bit Little Endian)
play INFO formats: can't set sample rate 44100; using 48000

Output File    : 'default' (alsa)
Channels       : 2
Sample Rate    : 48000
Precision      : 16-bit
Duration       : 00:00:02.21 = 105984 samples ~ 165.6 CDDA sectors
Sample Encoding: 16-bit Signed Integer PCM
Endian Type    : little
Reverse Nibbles: no
Reverse Bits   : no

the command line that worked gave me

Output File    : 'default' (pulseaudio)
Channels       : 2
Sample Rate    : 44100
Precision      : 32-bit
Duration       : 00:00:02.40 = 105984 samples = 180.245 CDDA sectors
Sample Encoding: 32-bit Signed Integer PCM
Endian Type    : little
Reverse Nibbles: no
Reverse Bits   : no

so the problem is this play command from the sox package that uses pulseaudio on command and alsa on crontab ...

the man of sox does not show how to specify the DRIVER, any hint ?

1 Answer 1

0

The player must lack one or more environment variables necessary to initialize PulseAudio. Most likely, XDG_RUNTIME_DIR.

Try exporting your entire environment into a file ((env; echo 'play -V4 /folder/file.ogg') >script.sh) and run it from cron using sh -a /path/to/script.sh. If that works, see which environment variables can be removed.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .