From: Russ P. on
I wrote a small csh script (on Linux) to run "make" (compile a
program). It works fine when I run it from the command line, but when
I try to run it with crontab, it doesn't work. I set the PATH variable
in the crontab file so it can find the script, but other environment
variables are apparently missing. How can I set the environment within
crontab to be exactly the same environment I have at the command line?
Thanks.

Russ P.
From: Bill Marcum on
On 2010-05-06, Russ P. <russ.paielli(a)gmail.com> wrote:
> I wrote a small csh script (on Linux) to run "make" (compile a
> program). It works fine when I run it from the command line, but when
> I try to run it with crontab, it doesn't work. I set the PATH variable
> in the crontab file so it can find the script, but other environment
> variables are apparently missing. How can I set the environment within
> crontab to be exactly the same environment I have at the command line?
> Thanks.
>
Include commands to set the environment variables in your script, or
source your .login or .cshrc files.


--
[It is] best to confuse only one issue at a time.
-- K&R
From: Kenny McCormack on
In article <25a68589-0f29-4950-bec8-db158cadf92c(a)h11g2000yqj.googlegroups.com>,
Russ P. <russ.paielli(a)gmail.com> wrote:
>I wrote a small csh script (on Linux) to run "make" (compile a
>program). It works fine when I run it from the command line, but when
>I try to run it with crontab, it doesn't work. I set the PATH variable
>in the crontab file so it can find the script, but other environment
>variables are apparently missing. How can I set the environment within
>crontab to be exactly the same environment I have at the command line?
>Thanks.
>
>Russ P.

(Some people will think this solution overdone, and will suggest smaller
little hacks - like, oh, set this, set that - but the fact is the only
good way to do it that really does ensure that you get the same
environment in crontab as you would logging in)

Setup the cron job to run an Expect script, that ssh's into the box
(using private key authentication so that no password is necessary),
then runs your script in the logged in session. I did this a long time
ago, and it worked out real well. Took a while to get all the pieces
working right (redirecting all of the stdio to /dev/null, so I didn't
get an email from every job). Nice also, because Expect provides
logging (as a built-in feature), so you get a nice log of your session,
almost for free.

--
> No, I haven't, that's why I'm asking questions. If you won't help me,
> why don't you just go find your lost manhood elsewhere.

CLC in a nutshell.

From: Keith Keller on
On 2010-05-06, Kenny McCormack <gazelle(a)shell.xmission.com> wrote:
>
> (Some people will think this solution overdone, and will suggest smaller
> little hacks - like, oh, set this, set that - but the fact is the only
> good way to do it that really does ensure that you get the same
> environment in crontab as you would logging in)
>
> Setup the cron job to run an Expect script, that ssh's into the box

You're right--that is overdone. Bill's suggestion to source the
appropriate login file(s) is much cleaner, and really does ensure that
you get a login environment, without having to learn Expect or configure
ssh keys.

--keith


--
kkeller-usenet(a)wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information

From: Russ P. on
On May 6, 11:54 am, Bill Marcum <marcumb...(a)bellsouth.net> wrote:
> On 2010-05-06, Russ P. <russ.paie...(a)gmail.com> wrote:> I wrote a small csh script (on Linux) to run "make" (compile a
> > program). It works fine when I run it from the command line, but when
> > I try to run it with crontab, it doesn't work. I set the PATH variable
> > in the crontab file so it can find the script, but other environment
> > variables are apparently missing. How can I set the environment within
> > crontab to be exactly the same environment I have at the command line?
> > Thanks.
>
> Include commands to set the environment variables in your script, or
> source your .login or .cshrc files.
>
> --
> [It is] best to confuse only one issue at a time.
>                 -- K&R

I tried that, but I can't seem to get it to load. I put

source ~/.cshrc

in the crontab file, but I got this reply:

crontab: installing new crontab
"/tmp/crontab.XXXXCGDs5E":4: bad minute
errors in crontab file, can't install.
Do you want to retry the same edit? y

What is the proper syntax? Thanks.

Russ P.