[Solved] Long cronjobs terminate after 2 minutes/Ubuntu 8.10

Erik Hemdal erik at comprehensivepower.com
Fri Mar 27 21:38:32 UTC 2009


> 
> On Fri, Mar 27, 2009 at 09:53:09AM -0400, Erik Hemdal wrote:
> > I use a cronjob to backup several directories on a Ubuntu
> 8.10 system.
> > This is done by a shell script which issues a series of commands on
> > each of several subdirectories.
> > 
> > When I run the script in the foreground, it takes about 2 hours to
> > complete, and it runs successfully.  When I run it in a cronjob, it 
> > terminates silently without an error after running for about two 
> > minutes.  
. . . .
> > I've already verified that the script is executable, that the full
> > path to the script is given in /etc/crontab, and that the 
> full path to
> > each command in the script is also specified.  I'm running
> the script
> > as root.  And there is an empty line at the end of my /etc/crontab
> > file (this was mentioned in one forum post I found as a requirement 
> > for cron to work right).  I've tried running the job with 
> nohup to try
> > to keep it alive.  Nothing has been successful.
> > 
> > Other brief cronjobs that I run under similar conditions work
> > correctly, but they take less than two minutes each to go.
. . . .
> > 
> Have you got your system set up so that cron sends mail to
> someone useful?  I.e. if there's a cron error do you get to 
> see the error message?
> 
> What user owns the crontab file being executed by cron?  If
> it's an ordinary user then that user should receive mail when 
> *any* text is output by the cron job. If it's being run by a 
> user who doesn't normally get mail then add a 
> "MAILTO=<someone who can read mail" to the beginning of the 
> crontab file and you may get some useful diagnostics.

Chris, thank you for the reply.

/etc/crontab is owned by root with filemode 644.

I discovered that no mail was in fact set up, so I installed the postfix and
bsd-mailx packages. I configured Postfix for local mail only and updated
/etc/crontab to send mail to my working user, not root.

With no other changes, the cronjob now appears to run properly.  Apparently
there's a dependency on postfix (which I had expected to be configured by
default, I guess).  I'm assuming that configuring the MTA is what did it.

Thanks for the reminder to make sure an MTA was running.






More information about the ubuntu-users mailing list