[GRLUG] crontab not running a working script
John-Thomas Richards
jtr at jrichards.org
Thu Jan 12 14:50:56 EST 2012
On Thu, Jan 12, 2012 at 12:48:30PM -0500, megadave wrote:
> On Thu, Jan 12, 2012 at 12:13, John-Thomas Richards <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> wrote:
> >> > I sync my box to 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.
> >
>
> When you issue the command manually, are you running as root (or using
> sudo) or as your own user?
You wound me. As root? No. I do system maintenance as root. I do
end-user stuff as end-user.`
> Also, are you putting this in the system crontab, root's crontab, or
> in your own user crontab?
I put it into my crontab (`crontab -e').
> If the "config" file is in ./home/user/.something - then if cron runs
> it as root its looking for /root/.something
Does this still apply given my answer above?
> If when it works you are running it as yourself (and NOT root), then
> it needs to either go in your own user crontab, or if in the system
> /etc/crontab, then you need to put your userid in the 'user' field,
> rather than root.
Ah. That answers my question. I run the script / crontab for my local
user, not as root.
--
john-thomas
------
A man builds a fine house; and now he has a master, and a task for life;
he is to furnish, watch, show it, and keep it in repair, the rest of
his days.
Ralph Waldo Emerson (1803-1882) [Society and Solitude, 1870]
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
More information about the grlug
mailing list