[SATLUG] I can not get cron jobs to run in Ubuntu Hardy Heron

John Pappas j at jvpappas.net
Mon Jul 7 16:00:28 CDT 2008


Hey Marc,

First off, you need to use the full path name for the commands that you want
to run.  Secondly, I would recommend placing those multiple step jobs in the
form of a script, and then croning the script.

I am breaking down your commands to see what the differences are so that the
script can be a bit more flexible (or just cron for the different times if
it is simply a time issue), but an example (I am by no means a powerful
shell scripter, so if any of those in the audience want to comment, please
do):

file name /var/adm/record.sh:
##########################
#!/bin/bash
# Useage: record.sh [HourNumber] [Duration]

# Define Variables
RECPATH=/home/mark/Desktop
FILEDATE=`/bin/date +%y_%m_%d`
FILENAME=C2C_$FILEDATE_H$1 # Will take the argument passed to the script to
add the _H1 to the name
DURATION=$2 # Will take the duration (either 3180 or 3300 based on your
examples)

/usr/bin/arecord -d $DURATION -c 1 -f S16 -r 32000 -D hw:1,0
$RECPATH/$FILENAME.wav
/usr/bin/lame -v -V9 $RECPATH/$FILENAME.wav $RECPATH/$FILENAME.mp3
rm $RECPATH/$FILENAME.wav
##########################

Regarding the shutdown, you will need to cron that as root and use the full
`/sbin/shutdown` path name.

HTH,
jp


On Mon, Jul 7, 2008 at 3:24 PM, Marc Ripley <misteratomic at gmail.com> wrote:

> I've set up a cron job to record some late night conspiracy radio but
> it never appears to run.
> My knowledge of linux is limited but I can create a crontab under my user.
> I've added my user account to the cron group.
> I'll include a copy of the crontab file here.
>
> ----------------
> 05 23 * * 1-5 cd /home/marc/Desktop ; arecord -d 3180 -c 1 -f S16 -r
> 32000 -D hw:1,0 C2C_`date +%y_%m_%d`_H4.wav ; lame -v -V9 C2C_`date
> +%y_%m_%d`_H4.wav C2C_`date +%y_%m_%d`_H4.mp3 ; rm C2C_`date
> +%y_%m_%d`_H4.wav #hour4m-f
> 05 00 * * * cd /home/marc/Desktop ; arecord -d 3300 -c 1 -f S16 -r
> 32000 -D hw:1,0 C2C_`date +%y_%m_%d`_H1.wav ; lame -v -V9 C2C_`date
> +%y_%m_%d`_H1.wav C2C_`date +%y_%m_%d`_H1.mp3 ; rm C2C_`date
> +%y_%m_%d`_H1.wav #hour1
> 05 01 * * * cd /home/marc/Desktop ; arecord -d 3300 -c 1 -f S16 -r
> 32000 -D hw:1,0 C2C_`date +%y_%m_%d`_H2.wav ; lame -v -V9 C2C_`date
> +%y_%m_%d`_H2.wav C2C_`date +%y_%m_%d`_H2.mp3 ; rm C2C_`date
> +%y_%m_%d`_H2.wav #hour2
> 05 02 * * * cd /home/marc/Desktop ; arecord -d 3300 -c 1 -f S16 -r
> 32000 -D hw:1,0 C2C_`date +%y_%m_%d`_H3.wav ; lame -v -V9 C2C_`date
> +%y_%m_%d`_H3.wav C2C_`date +%y_%m_%d`_H3.mp3 ; rm C2C_`date
> +%y_%m_%d`_H3.wav #hour3
> 05 03 * * 0 cd /home/marc/Desktop ; arecord -d 3180 -c 1 -f S16 -r
> 32000 -D hw:1,0 C2C_`date +%y_%m_%d`_H4.wav ; lame -v -V9 C2C_`date
> +%y_%m_%d`_H4.wav C2C_`date +%y_%m_%d`_H4.mp3 ; rm C2C_`date
> +%y_%m_%d`_H4.wav #hour4satn
> 05 03 * * 1 cd /home/marc/Desktop ; arecord -d 3180 -c 1 -f S16 -r
> 32000 -D hw:1,0 C2C_`date +%y_%m_%d`_H4.wav ; lame -v -V9 C2C_`date
> +%y_%m_%d`_H4.wav C2C_`date +%y_%m_%d`_H4.mp3 ; rm C2C_`date
> +%y_%m_%d`_H4.wav #hour4sunn
> ----------------
>
> Yes, I know it's crazy long but I have no experience with shell
> scripts.  I will later save these files to individual folders but this
> is my setup
>
> A separate cron job to shut down the computer after (hopefully) my
> scheduled recordings take place (owned by root) also fails.
>
> ----------------
> 10 4 * * 0-1 shutdown -h +2
> 10 3 * * 2-6 shutdown -h +2
> ----------------
>
> Don't know where to turn.  I've googled and searched but can not see
> where I am failing.
> I have very little understanding of chmod and it's ilk.  I barely know
> how to remove write protection of files.
>
> Well, thanks if you can help.
>
> --
> Marc
> --
> _______________________________________________
> SATLUG mailing list
> SATLUG at satlug.org
> http://alamo.satlug.org/mailman/listinfo/satlug to unsubscribe
> Powered by Rackspace (www.rackspace.com)
>


More information about the SATLUG mailing list