Bash script runs fine, but not in cron

Posted by radiotech on Ask Ubuntu See other posts from Ask Ubuntu or by radiotech
Published on 2014-06-06T14:34:40Z Indexed on 2014/06/06 15:41 UTC
Read the original article Hit count: 299

Filed under:
|
|
|
|

I have a script that's supposed to record a shoutcast stream for an hour, convert it to mp3, and then save it. The script runs correctly when I run it from the terminal, but I can't seem to get it to run in cron (where it should run every hour at the top of the hour).

Here's the line in crontab:

0 * * * * /medialib/tech/bin/recordstream 2>&1 >> /medialib/tech/cron.log

and here's the script:

#!/bin/bash
name="$(date +%s)"

mp3_name=$name.mp3
wav_name=$name.wav

timeout -sHUP 60m vlc -I dummy --sout "#transcode{channels=2}:std{access=file,mux=wav,dst=/medialib/stream_backup/wav/$wav_name" /medialib/tech/lib/listen.m3u

lame --mp3input /medialib/stream_backup/wav/$wav_name /medialib/stream_backup/$mp3_name

rm /medialib/stream_backup/wav/$wav_name

Thank you!

EDIT: Contents of cron.log (This text has been in the log file since it was transferred from an old server where it was working).

VLC media player 2.0.8 Twoflower
Command Line Interface initialized. Type `help' for help.
> Shutting down.
VLC media player 2.0.8 Twoflower
Command Line Interface initialized. Type `help' for help.
> Shutting down.

© Ask Ubuntu or respective owner

Related posts about 14.04

Related posts about bash