Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

play mp3 file using a cron job

General
mylo78
2006-12-15
2013-04-16
  • mylo78
    mylo78
    2006-12-15

    hey,

    I've been asked to continuously play an mp3, even after the power goes out.  So I'm thinking I'd like to set up a cronjob to check on the mp3blaster process, if it isn't running, start one.  Also, the output is the soundcard.  So far I haven't been able to do it.

    Any help would be appreciated :)
    <pre>
    #!/bin/bash
    # $COMMAND is the command used to create the reverse ssh tunnel
    COMMAND='mp3blaster -R myMP3file.mp3'

    # Is the tunnel up?
    CHECK_BLAST=`ps -eo args | grep "$COMMAND" | grep -v grep`

    # If the program is not up, create the music!
    if [ -z "$CHECK_BLAST" ] ; then
       $COMMAND
    fi
    </pre>