Help - Search - Members - Calendar
Full Version: Cron job issue
Linuxhelp > Support > Technical Support
Hi, can anyone explain this behavior to me and possibly sugest how to get the download file where I wan't it?

I'm trying to use mplayer to download a radio stream from the internet and I want to run it as a cron job. If I run this command in a terminal window as root I get the file output to the location/file I asked for (/home/ann/rips/Show.wav)

mplayer -cache 256 -playlist -ao pcm:file=/home/ann/rips/Show.wav -vc dummy -vo null -really-quiet

I know that if you don't specify a file in the -ao pcm option the default is ./audiodump.wav

If I try running it as root via cron job
46 15 * * 2 root mplayer -cache 256 -playlist -ao pcm:file=/home/ann/rips/Show.wav -vc dummy -vo null -really-quiet >/home/ann/rec.log 2>&1

the output is in /audiodump.wav (ie root's home) and not the location specified. I don't get any output if I try my user name in the crontab file.

The root partition (is that the right term?) does not have enough space to hold the download, if it did I would just use a shell script to download then move the file. I need to make it behave in cron as it does from a terminal window and write the output file where I say not the default. I've tried the Mpalyer lists and it seems to be a common problem that no one knows that answer to.

Thanks for any help you can give.
I would try putting it in a script anyways and see where that gets your. Just through the whole command in a bash script. Like this

#! /bin/bash

`mplayer -cache 256 -playlist -ao pcm:file=/home/ann/rips/Show.wav -vc dummy -vo null -really-quiet`

If you want to include your logging system, you can go a head and do that too. Just remember you need the ` ` to enclose the command. Then just run that sript from your cron, maybe that will work. Who knows.
QUOTE (Jim @ Jan 3 2006, 01:56 PM)
I would try putting it in a script anyways and see where that gets you.

Thanks, I've been trying to run it through a shell script and get the same result, it's fine from a terminal window but not as a cron job. I don't understand why they should be different when it's the same PC, OS, user etc. (The OS is Redhat9 by the way)

I don't get any output if I put user ann in the crontab command which I guess is because ann doesn't have rights to the root directory (/). But if the default location for the output is ./ (dot slash) shouldn't that be ann's home directory if the user is ann?
laugh.gif laugh.gif laugh.gif

Thanks Jim. While I was posting the last message it struck me that if I put a cd /home/ann in the shell script then ./ would be my home directory and it works. Doesn't explain the strange behavior of cron but hey ho, you can't have everything. smile.gif

For anyone seaching for the solution these are my crontab command and shell script.

21 7 * * 3 root /home/ann/rec >/home/ann/rec.log 2>&1


DATE=`date +%F`
echo "recording"
cd /home/ann/rips
rm /home/ann/rips/audiodump.wav  #remove previous audiodump.wav files
mplayer -cache 256 -playlist -ao pcm -vc dummy -vo null -really-quiet </dev/null &
#sleep 10800      #sleep for 3hrs
sleep 120    #sleep for 120sec
kill $!      #kill the mplayer job
echo "recording done"
lame /home/ann/rips/audiodump.wav /home/ann/rips/Show$DATE.mp3
echo "all done :)"
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2017 Invision Power Services, Inc.