Results 1 to 2 of 2

Thread: sound in cronjob problem

  1. #1
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default sound in cronjob problem

    Hi,

    I have a little cronjob placed in /etc/cron.d/mine:

    [CODE]
    > -0,30 * * * * cer /home/cer/bin/avisar_hablando hora >> /tmp/avisar_hablando.log

    [CODE]


    The script does this:

    Code:
    
    > #!/bin/bash
    > MAILTO="nobody"
    >
    > TEMPORAL=`mktemp /tmp/decir.wav.XXXXXXXXXXXXX`
    > ERROR=$?
    > case $ERROR in
    >   0) ;;
    >   *) echo "Error $ERROR in mktemp"
    >      exit
    >      ;;
    > esac
    >
    >
    > case "$1" in
    >
    >         hora)
    >              LANG=es_ES.ISO-8859-1 LC_ALL=es_ES.ISO-8859-1 /bin/date +"Es %e de %B, y son las %k horas y %-M minutos " | espeak -v es --stdin -a 20 -w $TEMPORAL
    >         ;;
    > esac
    >
    > if test -f $TEMPORAL ; then
    >         ALSA_CONFIG_PATH=/etc/alsa-pulse.conf SDL_AUDIODRIVER=pulse /usr/bin/aplay -q $TEMPORAL
    >         rm $TEMPORAL
    > fi

    Or, in short:


    Code:
    
    > LANG=es_ES.ISO-8859-1 LC_ALL=es_ES.ISO-8859-1 /bin/date +"Es %e de %B, y son las %k horas y %-M minutos " | espeak -v es --stdin -a 20 -w /tmp/temporary
    > ALSA_CONFIG_PATH=/etc/alsa-pulse.conf SDL_AUDIODRIVER=pulse /usr/bin/aplay -q /tmp/temporary

    Or, if you prefer in English:

    Code:
    
    > /bin/date +"%B %e, %k hours %-M minutes " | espeak -v en --stdin -a 20 -w /tmp/temporary
    > ALSA_CONFIG_PATH=/etc/alsa-pulse.conf SDL_AUDIODRIVER=pulse /usr/bin/aplay -q /tmp/temporary

    The idea is a speaking clock: it speaks the time every half hour. If I
    call it from the command line, it works fine. If it runs as a cronjob,
    it works for weeks, then suddenly it stops working like this:

    Code:
    ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
    aplay: main:731: audio open error: Device or resource busy
    I inmediately run it from the CLI, and it works.


    Perhaps something else instead of "aplay" to play the WAV file? I'll try
    'paplay'... the problem is, it might not work if the desktop is not
    loaded, because then pulse is not loaded.

    --
    Cheers / Saludos,

    Carlos E. R.
    (from 12.3 x86_64 "Dartmouth" at Telcontar)

  2. #2
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: sound in cronjob problem

    On 2013-06-26 12:53, Carlos E. R. wrote:

    > Perhaps something else instead of "aplay" to play the WAV file? I'll try
    > 'paplay'... the problem is, it might not work if the desktop is not
    > loaded, because then pulse is not loaded.


    Nope. paplay fails with:

    Connection failure: Connection refused
    pa_context_connect() failed: Connection refused

    --
    Cheers / Saludos,

    Carlos E. R.
    (from 12.3 x86_64 "Dartmouth" at Telcontar)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •