[GRLUG] crontab not running a working script

Bob Kline bob.kline at gmail.com
Thu Jan 12 14:54:26 EST 2012


On Thu, Jan 12, 2012 at 2:45 PM, John-Thomas Richards <jtr at jrichards.org>wrote:

> On Thu, Jan 12, 2012 at 12:28:55PM -0500, Michael Mol wrote:
> > Bob Kline wrote:
> > >
> > >
> > > On Thu, Jan 12, 2012 at 12:13 PM, John-Thomas Richards
> > > <jtr at jrichards.org <mailto:jtr at jrichards.org>> wrote:
> > >
> > >     On Thu, Jan 12, 2012 at 12:04:17PM -0500, Ben Rousch wrote:
> > >     > On Thu, Jan 12, 2012 at 11:47 AM, John-Thomas Richards
> > >     > <jtr at jrichards.org <mailto:jtr at jrichards.org>> wrote:
> > >     > > I sync my box to memotoo.com <http://memotoo.com>'s service.
> > >      Works from the commandline with
> > >     > > `syncevolution memotoo'.  The password is in the config files
> so
> > >     when I
> > >     > > enter the above command, it syncs, then I'm back to a command
> > >     prompt.  I
> > >     > > can take that command and put it in a simple bash script:
> > >     > >
> > >     > >        #!/bin/bash
> > >     > >        syncevolution memotoo
> > >     > >
> > >     > >
> > >     > > It works as expected; no further input is needed.  However,
> when
> > >     I put
> > >     > > that script into my crontab, I get this error message:
> > >     > >
> > >     > >        Enter password for memotoo: [ERROR] error code from
> > >     > >        SyncEvolution fatal error (local, status 10500): could
> > >     not read
> > >     > >        password for memotoo
> > >     > >
> > >     > >        Synchronization failed, see
> > >     > >
> > >
>  /home/jtr/.cache/syncevolution/memotoo-2012-01-12-11-38/syncevolution-log.html
> > >     > >        for details.
> > >     > >
> > >     > > The error log simply repeats that it could not read the
> password.
> > >     > >
> > >     > > My scripting skills are limited; am I missing something?  If it
> > >     works
> > >     > > from a commandline should it not also work from cron?
> > >     >
> > >     > Cron uses different paths than a normal user. To avoid problems
> with
> > >     > this you should specify the full path to all executables and
> files in
> > >     > a cron job. You'll likely have to tell the program exactly where
> the
> > >     > config file is located.
> > >
> > >     Is this true even when the command in cron is a bash script?  The
> line
> > >     in crontab is:
> > >
> > >     1 23 * * * /home/jtr/bin/syncmemotoo
> > >
> > >     It runs every night at 11:00PM.
> > >
> > >
> > > But does your script need your environment?
> > > The absolute path gets your script, but under
> > > what environment does cron run it?
> > >
> > > The crontab(1) points out that a user can have
> > > their own crontab file, but seems a little vague
> > > about whether that implies anything about the
> > > user's own environment.
> > >
> > > Can you direct any error messages when
> > > the command is run to yourself?
> >
> > By default, cron emails the output of commands to the user the command
> > was run as, or root if it's a system cron job.
> >
> > So, the output of the command should be in his inbox.
>
> The output of the command is as I mentioned: could not read password.
> --
>
So if root is running cron, then it's
"could not read" as in could not find?

So you can redirect the file containing
your password to your script?  Absolute
path.  I think everything at the end of the
crontab entry is your stuff, so you can
use "< file".

Or something thereabouts.  Do you use
a "read" commend in your script?

   -- Bob

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shinobu.grlug.org/pipermail/grlug/attachments/20120112/df6d3471/attachment.html>


More information about the grlug mailing list