PDA

View Full Version : cron ends jobs early?



Mateo
January 2nd, 2007, 09:03 PM
i am trying to get cron to record an internet radio show daily. I created a script which runs streamripper and then gets rid of unnecessary files after it's done. I set up crontab to run the script every day at a specific time, and it does so, but it cuts off after only downloading about 1megabyte (about 15 minutes, I think), while I have the script set up to record for 3 hours. When I run the script on my own, it doesn't stop after 1megabyte is downloaded. Only in crontab.

Does crontab stop jobs? what could be my possible mistake here?

Mateo
January 3rd, 2007, 07:20 PM
i'm going to go ahead and bump this, just in case someone knows of something about how long crontab waits on jobs.

i'll do some testing later to see if I can pin down for sure that the problem is with crontab (by making sure the file size is consistently more or less the same, by timing the jobs, and testing the script both myself and with crontab). then we can see where we should go from there, to pinpoint where the problem is.

Mateo
January 3rd, 2007, 10:34 PM
ok, testing complete.

When running the script on my own, it works fine.

When running the script with crontab, the file is always 1008kb in size. Always. I even changed the length to download with streamripper, but still 1008kb.

So it's obviously something with crontab. It's stopping streamripper after 1008kb. Why could that be?

Mateo
January 5th, 2007, 05:56 AM
here's the cron command I am using:

00 10 * * 1-5 /home/user/.script


I also tried

00 10-13 * * 1-5 /home/user/.script

with no luck. still 1008kb.

Mateo
January 6th, 2007, 07:50 PM
bump

Mateo
January 9th, 2007, 07:56 PM
bump

eteran
January 9th, 2007, 11:31 PM
Thats not enough information. Please tell us the language the script is written in and if possible you could post the whole script/relevant parts.

Some scripting languages have limited runtime for a single script. PHP for example is limited to 15 minutes by default iirc. Anyways, I think the script you're using is causing the malfunction, not the crontab.

Mateo
January 10th, 2007, 12:17 AM
Thanks for responding eteran. It is a bash script. I know that the problem is cron related because I have tested the script by itself and it works 100% as wanted. only the problem occurs when using cron..

But it appears to have fixed itself. I don't know what, I haven't touched the script or basic commands of cron (only adjusted the times a bit for testing). One of the weird things about Linux. Something might not be working one minute, but working fine the next.

LotsOfPhil
January 11th, 2007, 06:08 PM
Just a thought, you could run it in the background:

00 10 * * 1-5 /home/user/.script &

grahams
January 19th, 2007, 08:31 PM
I believe streamripper outputs too much to stdout and this screws up cron.

Try adding ">/dev/null 2>&1" to the end of the command in crontab. This directs streamrippers text and error text to /dev/null. This works for me

My crontab looks like this
# crontab -l
# m h dom mon dow command
00 11 * * 5 tsocks streamripper http://205.234.249.144:80 -d ~/Music/ -l 7200 >/dev/null 2>&1
00 16 * * 1-5 tsocks streamripper http://205.234.249.144:80 -d ~/Music/ -l 3600 >/dev/null 2>&1

devilbush
March 3rd, 2007, 04:51 AM
I believe streamripper outputs too much to stdout and this screws up cron.

Try adding ">/dev/null 2>&1" to the end of the command in crontab. This directs streamrippers text and error text to /dev/null. This works for me

My crontab looks like this
# crontab -l
# m h dom mon dow command
00 11 * * 5 tsocks streamripper http://205.234.249.144:80 -d ~/Music/ -l 7200 >/dev/null 2>&1
00 16 * * 1-5 tsocks streamripper http://205.234.249.144:80 -d ~/Music/ -l 3600 >/dev/null 2>&1

This is just the tip I was looking for. Works like a charm. Thank you!

db

tweston
November 18th, 2007, 03:33 AM
if you invoke your script from crontab, you need the --quiet option for the streamripper command within that script

interestingly, this isn't true if you start the same script directly as a command line (even with the "&" background option)

tweston
December 11th, 2007, 03:50 AM
when running streamripper from crontab, you need to suppress the text output from streamripper

use the --quiet option in the streamripper command line

naildeca
July 18th, 2010, 08:46 PM
Thanks, grahams and tweston, using the --quiet option seems to have solved my problem. It is odd that I did not have a problem when I was running Dapper Drake or Hardy Heron but upon upgrade to Lucid Lynx the problem cropped up for me. At the time of most of this tread you all were running the earlier versions, same as I was and I was not having this problem.