Cron not executing my tasks.

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read this

Cron not executing my tasks.

Postby glore2002 on Sun Jul 13, 2008 11:24 am

Hello!

I have a script (tape) which records tv from the tv tuner card using Mencoder. I saved this script in /bin and can execute it from anywhere (so, it is added to my $PATH). Its format is: tape 12 test 00:02:00 (this means recording channel 12 during 2 minutes and calling the file test). I also made the script executable.

In Ubuntu 7.04 and in Slackware it works great if I added it to cron via crontab -e or kcron. But, when I do this in Mint or Ubuntu 8.04, nothing happens. It just doesn't record anything and I don't understand why. If, instead of adding the task to cron, I run the script from the command line, it works ok. So, I am a bit confused! :?:

This is the way the script is written to cron when using kcron:
Code: Select all
0 12 13 7 7  tape 12 tvprogram 00:02:00


This means. Record at 12pm day 13 (today - Sunday). Execute the script tape which is in /bin folder. Do it during 2 minutes. Call the file tvprogram.

Any help will be appreciated.

Thanks,
Glore2002.-
glore2002
Level 1
Level 1
 
Posts: 25
Joined: Sat Jul 12, 2008 11:36 am

Linux Mint is funded by ads and donations.
 

Re: Cron not executing my tasks.

Postby Mr. Blue on Sun Jul 13, 2008 9:35 pm

Try using /bin/tape instead of just tape and enclose it in quotes like this:

Code: Select all
0 12 13 7 7  "/bin/tape 12 tvprogram 00:02:00"


Also, I think Ubuntu 8.04 uses dash as the default shell instead of bash. Not 100% sure though. Might be useful to change the top of your script to #!/bin/bash if cron doesn't like it.

Hope it works out.
...and that should work...theoretically.
User avatar
Mr. Blue
Level 2
Level 2
 
Posts: 69
Joined: Sun Jul 13, 2008 9:25 pm

Re: Cron not executing my tasks.

Postby glore2002 on Mon Jul 14, 2008 4:59 am

Thanks for you reply Mr Blue but with quotation marks the same thing happened (just nothing being recorded). As you can see #!/bin/bash was already on top of it.

Here is my script (maybe it can be of some help too).

Code: Select all
#!/bin/bash
#
# script to encode tv using mencoder
#
# usage tape <channel#> <name> <duration>
#
CHAN="$1"
FNAME="$2"
DURATION="$3"

if [ $# -ne 3 ]
then
echo "Usage tape <Channel> <Name> <duration>"
echo "duration = hh:mm:ss"
exit
fi

echo
echo "Taping " "$FNAME""_`date +%m%d`"
echo

mencoder tv:// -tv driver=v4l:device=/dev/video0:width=320:height=288:fps=25:norm=palnc:chanlist=us-cable:channel=$CHAN:saturation=-20:contrast=-20:audiorate=48000:immediatemode=0 -vf denoise3d -oac mp3lame -lameopts fast:preset=medium -ovc lavc -lavcopts vcodec=mpeg4:vqscale=4:aspect=4/3 -endpos $DURATION -ffourcc DX50 -o "$FNAME"_`date +%m%d`.avi -quiet


Thanks again,
Glore2002.-
glore2002
Level 1
Level 1
 
Posts: 25
Joined: Sat Jul 12, 2008 11:36 am

Re: Cron not executing my tasks.

Postby Mr. Blue on Mon Jul 14, 2008 4:33 pm

The script works fine when you run it yourself on the command line, so there's no problem with it.

All I can suggest is to use full paths in the script. In this case add the full path to mencoder:

Code: Select all
#!/bin/bash
#
# script to encode tv using mencoder
#
# usage tape <channel#> <name> <duration>
#
CHAN="$1"
FNAME="$2"
DURATION="$3"
mencoder=/usr/bin/mencoder


That's all I can suggest. Cron really likes full paths to the programs it executes. Good luck with it.
...and that should work...theoretically.
User avatar
Mr. Blue
Level 2
Level 2
 
Posts: 69
Joined: Sun Jul 13, 2008 9:25 pm

Re: Cron not executing my tasks.

Postby glore2002 on Mon Jul 14, 2008 5:45 pm

Thanks again Mr. Blue.
I've added full path to mencoder but nothing happened again :-( This problem is driving me crazy. I don't know what to do.

Thanks again,
Glore2002.-
glore2002
Level 1
Level 1
 
Posts: 25
Joined: Sat Jul 12, 2008 11:36 am

Re: Cron not executing my tasks.

Postby glore2002 on Tue Jul 15, 2008 4:57 am

Is cron working ok for everyone except me? :-(

I've tried as root and same results: Nothing being recorded!
How do I start/restart cron in Mint?

Thanks,
Glore2002.-
glore2002
Level 1
Level 1
 
Posts: 25
Joined: Sat Jul 12, 2008 11:36 am

Re: Cron not executing my tasks.

Postby chattr on Tue Jul 15, 2008 3:47 pm

glore2002 wrote:
[snip]

This is the way the script is written to cron when using kcron:
Code: Select all
0 12 13 7 7  tape 12 tvprogram 00:02:00


This means. Record at 12pm day 13 (today - Sunday). Execute the script tape which is in /bin folder. Do it during 2 minutes. Call the file tvprogram.

[snip]

Reply:

It looks as if the user field is missing, so maybe cron reads ' tape ' as the user.

Try putting this in /etc/crontab :
Code: Select all

# m h dom mon dow user command

0 12 13 7 7  root /bin/tape 12 tvprogram 00:02:00




chattr
Level 2
Level 2
 
Posts: 58
Joined: Thu Jul 03, 2008 2:43 pm

Linux Mint is funded by ads and donations.
 

Return to Newbie Questions

Who is online

Users browsing this forum: Google Adsense [Bot], Reorx, WJacques and 34 guests