Newbie question.

  • Follow


We have a basic webserver (the one that installs with linux, apache I think) 
and we have another internal server that tracks defects.  Now I can run a 
script call Report from the command line as user and get the information 
that I need.  So what we decided to do was make a crontab that would call a 
script file.  In that script file we have a call to Report and we place the 
output of Report to a readme file in the pub directory of the server.

If we run the script file in a normal shell it works fine the new file is 
generated and everything.  But within the crontab it does nothing.  At first 
we saw an error saying the Report command was not found, we fixed that but 
it still does not work.  What are we doing wrong?

Thanks. 


0
Reply defsetup (6) 3/20/2006 7:25:19 PM

On 2006-03-20, Arint� <defsetup@hotmail.com> wrote:
> We have a basic webserver (the one that installs with linux, apache I think) 
                                                        ^^^^^

There are many linux distributions; in the future you'll want to note
which one.  Slackware and RedHat come with different major versions of
apache, for example.

> If we run the script file in a normal shell it works fine the new file is 
> generated and everything.  But within the crontab it does nothing.  At first 
> we saw an error saying the Report command was not found, we fixed that but 
> it still does not work.  What are we doing wrong?

"It still does not work" is a singularly poor problem report.  What goes
wrong?  What errors do you see?  What does the mail sent by cron say,
for example?  Since it works from a login shell, but not from crontab,
it's probably an environment issue, but without more detail from you
nobody could reliably guess which environment variables you need (or
even if it's a different problem altogether).

--keith

-- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
see X- headers for PGP signature information

0
Reply kkeller-usenet (1289) 3/20/2006 8:21:30 PM


On Mon, 20 Mar 2006 14:25:19 -0500, Arint� 
  <defsetup@hotmail.com> wrote:
> We have a basic webserver (the one that installs with linux, apache I think) 
> and we have another internal server that tracks defects.  Now I can run a 
> script call Report from the command line as user and get the information 
> that I need.  So what we decided to do was make a crontab that would call a 
> script file.  In that script file we have a call to Report and we place the 
> output of Report to a readme file in the pub directory of the server.
>
> If we run the script file in a normal shell it works fine the new file is 
> generated and everything.  But within the crontab it does nothing.  At first 
> we saw an error saying the Report command was not found, we fixed that but 
> it still does not work.  What are we doing wrong?
>
> Thanks. 
>
I don't know exactly what you are doing, but some facts to remember 
about crontab are:
the PATH is shorter than usual; usually it contains just "/usr/bin:/bin"
other environment variables might not be set
the % character has a special meaning

See "man 5 crontab".

-- 
Put your best foot forward.  Or just call in and say you're sick.
0
Reply bmarcum (929) 3/20/2006 8:48:02 PM

Arint=E9 wrote:
> We have a basic webserver (the one that installs with linux, apache I thi=
nk)
> and we have another internal server that tracks defects.  Now I can run a
> script call Report from the command line as user and get the information
> that I need.  So what we decided to do was make a crontab that would call=
 a
> script file.  In that script file we have a call to Report and we place t=
he
> output of Report to a readme file in the pub directory of the server.
>
> If we run the script file in a normal shell it works fine the new file is
> generated and everything.  But within the crontab it does nothing.  At fi=
rst
> we saw an error saying the Report command was not found, we fixed that but
> it still does not work.  What are we doing wrong?


You provide little information, so I'll guess at a few possible issues.

Since the script works for you, the first thing we may want to look at
is what user is the process in crontab running as ? If it is running as
anything but you, then we need to look at the difference between you
and that other user. First, log on as user X and step through the
script manually. That may help you find the problem fairly quick if the
script isn't too long.

The main problem here would be rights and environment variables. The
shell may also be an issue.

For rights/permissions, look at all the resources the script is
accessing and make sure that the other user has the needed permissions.
If you run the cron job as user X, and it writes to your personal
directory, the user X needs permission to write to your directory.
Since this is a two system setup, you need to make sure user X has the
proper permissions to resources on both systems.

Next we have environment variables. Does your script explicitly access
any environment variables ? If so, then su to user X and echo out the
variables. If they are not what you get as yourself, then you may have
found the problem. You may need to copy some .profile or .(shell)rc
info to the appropriate files. You may need to do this even if it is
running as you, as some files are only loaded for "login" shells.
Things like path data can be avoided by specifying complete paths. You
can also use "su" and "which" to see if there are any differences in
commands being used.

Another thing can be the shell. If user X is setup for a different
shell, and the script doesn't specify a shell, then you need to correct
one or the other. Add the shell to the top of the script to make sure
the script is run under a particular shell.
#!(path of shell)

There are many other things it could be as well, so why don't you tell
us more ? Does part of the script work, but not another ? Is a certain
command failing ? Do you get any error message ? What version and disto
of Linux ? What version of Apache ? If it is not confidental, post the
part of Report that isn't working.


Dean G.

0
Reply Dean 3/20/2006 11:55:37 PM

I guess it was the path because it is now working....

Thanks for your help and next time i will be more specific.


0
Reply defsetup (6) 3/21/2006 1:42:00 PM

4 Replies
34 Views

(page loaded in 0.082 seconds)

Similiar Articles:













7/23/2012 2:32:02 AM


Reply: