Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Cron Jobs Newbie Questions

0 views
Skip to first unread message

DeifieD

unread,
Jun 13, 1999, 3:00:00 AM6/13/99
to
Hi everyone,

I have a user that wants to run a cron job to print a report everyday. User
and root can run the script on the command line and it works just fine but
when it is in users crontab user get the message that the utility in the
script is not found.

Any recommendations on what book will give more information about cron jobs?

Please help.

Frank Brauer

unread,
Jun 13, 1999, 3:00:00 AM6/13/99
to
May be that the requested tool is in a path which is not in $PATH when you
run the script (because the 'login' is different). You can add the path in
the script (i.e. ls -> /bin/ls). You can check with with something like
env, set or setenv (depends on your shell) on the top of your script and
redirect the output in a file. So you can check the environment of this cron
job and add everything you need in your script.

Hope this helps

Frank

DeifieD schrieb in Nachricht <7k07a5$50v$1...@ffx2nh5.news.uu.net>...

MichaelAKalus

unread,
Jun 13, 1999, 3:00:00 AM6/13/99
to
Check the form.

If the script is not in the path then you should e.g. call it something like
this:

/export/home/~user/script.sh

instead of only calling it with the name. script.sh

Hope that helps.

Michael Kalus
DeifieD <eta...@nospam.mc.net> wrote in message
news:7k07a5$50v$1...@ffx2nh5.news.uu.net...

Andrzej Bort

unread,
Jun 14, 1999, 3:00:00 AM6/14/99
to
MichaelAKalus <Michae...@email.msn.com> wrote:
> /export/home/~user/script.sh
^
eeek? AFAIK, "~" is not valid char in username (yes, I know, username
and home dir don't need to be identical). ;-)

> instead of only calling it with the name. script.sh

BTW: check file attributes (chmod u+x script).

--
Andrzej Bort, bort<at>polsl.gliwice.pl *** My personal opinions ***


Kurt J. Lanza

unread,
Jun 14, 1999, 3:00:00 AM6/14/99
to
DeifieD wrote:
>
> Hi everyone,
>
> I have a user that wants to run a cron job to print a report everyday. User
> and root can run the script on the command line and it works just fine but
> when it is in users crontab user get the message that the utility in the
> script is not found.
>
> Any recommendations on what book will give more information about cron jobs?
>
"man cron" and "man crontab". One of them describes the simple
environment under which cron jobs are run. Read the man pages. The man
pages are your friend. First thing, try the man pages.

MichaelAKalus

unread,
Jun 14, 1999, 3:00:00 AM6/14/99
to
Andrzej Bort <bo...@polsl.gliwice.pl> wrote in message
news:7k2tcs$o44$2...@zeus.polsl.gliwice.pl...

> MichaelAKalus <Michae...@email.msn.com> wrote:
> > /export/home/~user/script.sh
> ^
> eeek? AFAIK, "~" is not valid char in username (yes, I know, username
> and home dir don't need to be identical). ;-)

gee, thanks :)

>
> > instead of only calling it with the name. script.sh
>
> BTW: check file attributes (chmod u+x script).

I don't think that is the problem as he said he can execute it on the shell.

Michael

DeifieD

unread,
Jun 14, 1999, 3:00:00 AM6/14/99
to
Thanks guys,

You gave me some ideas.

I will try them out.


Kurt J. Lanza wrote in message <3765080B...@inforonics.com>...

Mark Lambert

unread,
Jun 15, 1999, 3:00:00 AM6/15/99
to
Andrzej Bort wrote:
>
> MichaelAKalus <Michae...@email.msn.com> wrote:
> > /export/home/~user/script.sh
> ^
> eeek? AFAIK, "~" is not valid char in username (yes, I know, username
> and home dir don't need to be identical). ;-)
>
> > instead of only calling it with the name. script.sh
>
> BTW: check file attributes (chmod u+x script).
>
> --
> Andrzej Bort, bort<at>polsl.gliwice.pl *** My personal opinions ***

Basic point about cron. It does not have the slightest idea about environment.
It is run by the cron daemon which has a basic path, shell and a few other
environment details and thats IT.

It tripped me up many times when learning scripting :)
If you want to execute a script you must make sure that the script itself sets
any environment variables like PATH LPDEST etc, as well as any specific user
variables like MYFILES or DBNAME.
You can do that specifically in the script, or simply source the user's
profile.
in csh its source /full/path/name/.login
in sh or ksh its . /full/path/name/.login

to test that thats the problem, put:
env > /tmp/cronjob.cron
as the first line in the cronjob and have cron kick it off.
then change it to:
env > /tmp/cronjob.cmdline
and run it from the command line.
check out the differences in the environments. Put the missing bits explicitly
in the cronjob.

The moral of the story is: never assume a script inherits the environment you
want it to. Especialy if you run it from cron.
--
/\ The Fulcrum Consulting Group Mark Lambert - Consultant
/\O\ Professional Services For Operation Mark.L...@fulcrum.com.au
/ /\ Of A Networked Computing Environment ph: +61-3-9621-2100
/o | \ 12/10-16 Queen St, Melbourne VIC 3000, Australia fx: +61-3-9621-2724

LJ

unread,
Jun 18, 1999, 3:00:00 AM6/18/99
to
You should look at the 'su' command, parm -c allows you to specify commands and
being able to use a user environment.

I think cron should not complain about the password, also crons can be setup
for users also which is probably the cleanest. System upgrades tend to wipe out
the system cron file.

0 new messages