[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Cron jobs run out of memory?



I have a simple download script that runs from a cron job every morning
to pull an audio stream from a url and then convert it to mp3 (the
script is attached to this e-mail). It runs fine the first couple times
after a reboot, but then fails at various stages, leaving these messages
in my mailbox:

/home/jacob/bin/download.sh: fork: Cannot allocate memory

/home/jacob/bin/download.sh: xrealloc: ../bash/subst.c:468: cannot
reallocate 99 178368 bytes (0 bytes allocated)

When it gives the fork error, it has usually made it through the mplayer
section but not lame. When it gives the xrealloc error it doesn't even
make it that far. However, when I run this script manually from a
command line it works perfectly.

The computer is an Athlon 2200+XP on a NForce2 chipset with 512MB of ram
and 160GB SATA. Here is an example output from 'free' after the cron job
has failed, but running the program manually worked fine:

$ free
       total       used       free     shared    buffers  cached 
Mem:  516308     514288       2020          0       1712  101836
-/+ buffers/cache:410740    105568 
Swap: 497968     467868      30100

Any suggestions what might be causing this out of memory problem, or
ways to work around it?

TIA,
Jacob
#!/bin/bash

weekday=`date +%a`
today=`date +%G%m%d`
workingloc="/path/to/dir/"
tempfile=audio.wav
ourfile=${today}.mp3

cd "$workingloc"

if [ -f "$tempfile" ]; then

  rm $tempfile

fi

if [ "$weekday" != 'Sat' ] && [ "$weekday" != 'Sun' ]; then

  domplayer=`mplayer -ao pcm -aofile $tempfile -vo null -vc dummy -playlist http://somedomain.com/url/file${today}.ram 2>&1`

fi

if [ -f "$tempfile" ]; then

  dolame=`lame --vbr-new -V2 --scale 8 $tempfile $ourfile 2>&1`

fi

if [ -f "$ourfile" ]; then

  doxmms=`xmms -e $ourfile`

fi


Reply to: