Casey Bralla on 24 Aug 2008 16:10:26 -0700


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

Re: [PLUG] Why does it produce a silent error when run from crontab?


Eric (and Ugarit), thanks for your thoughts.

I didn't show it in my eMail, but I do cd to the correct directory as the 
first action in the script.   If I start running the script from a different 
directory from the command line , it still works.

I have also been able to successfully run the program using the "sh" shell 
from the command line.   Changing the shell to full bash in crontab didn't 
help.   Likewise, changing the path to match the normal bash default path 
didn't help either.

The "root" statement in the crontab file tells the script to run with root 
privileges.  (Not too secure, I know, but I'm the only user on the system).



I'm wondering if the libraries used by jpegtopnm aren't being missed in the 
crontab environment somehow.   Got any ideas how I could test for that?





On Sunday 24 August 2008 5:52:45 pm Eric wrote:
> Casey:
>
> crontab jobs run with what I call a "stunted" environment... there is
> only a very rudimentary path and little else.  I'm not sure where it
> starts in the directory tree but always cd to where you want to be
> running the script first thing.  Also, they start executing under
> /bin/sh and not bash. (You're right to have #!/bin/bash as the first
> line of your script.).  Check other environment dependencies for your
> programs if that does not solve the problem.
>
> HTH
>
> Eric
>
> Casey Bralla wrote:
> > I've got a small batch program that creates a nifty near-realtime view of
> > the earth with animated cloud cover
> > (http://www.nerdworld.org/nerdspace.html) that **used** to work, but now
> > doesn't on my Debian 4 server.
> >
> > I can run the program just fine from a command prompt, but it fails in a
> > very strange way when run from crontab.
> >
> > The program has to do some image manipulations, and to do so it
> > calls "jpegtopnm" (part of "netpbm") to convert some jpg files into pnm
> > format.
> >
> > Oddly, I can run the conversion script from a bash shell prompt without
> > any trouble, but the program bombs weirdly if run from crontab.   When it
> > bombs, it doesn't halt or give any kind of error message;  but jpegtopnm
> > just creates a pnm file of zero length.
> >
> >
> > So, to summarize:
> >
> > When jpegtopbm runs in a script started from command prompt, it runs
> > fine. But when it runs in the same script started by crontab, it bombs
> > silently without creating the pnm image file.
> >
> >
> >
> >
> >
> > Here's an abbreviated version of the script file:
> >
> > #!/bin/bash
> >
> > # Create globe images with xplanet.  Create xplanet00.jpg
> > /usr/bin/xplanet -body earth -num_times 1 -verbosity 1 -config
> > xplanet00.cfg -latitude 39.81 -longitude -75.90 -geometry 1003x752
> > -starfreq 0 -projection orthographic -output xplanet00.jpg
> >
> > # Convert to intermediate format "pnm"
> > /usr/bin/jpegtopnm -verbose xplanet00.jpg>  xplanet00.pnm
> > # (This is the line that does not work in batch mode)
> >
> >
> >
> >
> >
> >
> > The crontab line looks very normal:
> > 0,15,30,45 * * * *       root   /path/create.xplanet.images
> >
> >
> >
> >
> >
> > Anybody have any suggestions of where to explore troubleshooting this
> > problem?
> >
> > All my error logs are clean.  Nothing looks amiss, except that it doesn't
> > work.<sigh>



-- 


Casey Bralla
Chief Nerd in Residence
The NerdWorld Organisation
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug