schaefer@bgsuvax.UUCP (Stephen Schaefer) (07/25/85)
We run 4.2BSD on a VAX 11/785, with source code licenses. Our csh
scripts run correctly when run by root from a command shell, but do not
run correctly when run by cron. Sh scripts *do* run correctly when run
by cron. Csh scripts run from cron do nothing (so far) which produces
side effects other than to be entered into the acct file as having been
run by root and taken 0 seconds (according to lastcomm). I have tried
many variations on the permissions, ownership and the manner of
invocation, including cron lines like
* * * * * /usr/local/test.csh
* * * * * /bin/csh /usr/local/test.csh
I've also tried redirecting the stdin and stdout on the invocation line
to the console, in case csh demands those be attached to something
(un?)reasonable, but no change, and I doubt that to be the problem. The
test script which I've been using consists of
#! /bin/csh
echo 'set >> /tmp/sps1' > /tmp/sps1
set >> /tmp/sps1
echo >> /tmp/sps1
echo 'printenv >> /tmp/sps1' >> /tmp/sps1
printenv >> /tmp/sps1
So far, I've had to assume that the variables and environment variables are
the default. I looked at the cron source, and it starts the process up with
a line like
execl("/bin/sh", "sh", "-c", s, 0);
where s is a pointer to a string containing the invocation line, less
the startup time symbols. I've gone so far as to try to start the
script indirectly with an executable program like this Bourne shell
script:
exec /usr/local/test.csh
or even this compiled C program:
main()
{
execl("/usr/local/test.csh", "test.csh", 0);
}
In every case, it works correctly when run by root from a command shell
(both csh and sh work) but not when initiated by cron. I'm now asking
for help from the community. If there is sufficient interest, I will
post the solution.
I may be reached at:
UUCP: ....!cbosgd!osu-eddie!bgsuvax!schaefer
CSNET: schaefer@bgsuvax.CSNET
Many thanks in advance,
Stephen P. Schaefer
P.S.
I don't mind people MAILING me flames about csh, but let's not
waste everyone's time with them?
"If you are made to wait, it is only to serve you better."
- quoted in "The Mythical Man Month" by F. P. Brooks.
schaefer@bgsuvax.UUCP (Stephen Schaefer) (07/29/85)
Thanks to everyone who sent help. The reason that the csh script would not run from cron was that it was trying to run /.cshrc and failing because of a bad/nonexistent environment variable. The solution was thus to use an entry of the form * * * * * /bin/csh -f /usr/local/test.csh (The only reason I don't feel stupid is that, though I received many insightful suggestions, I actually found the problem myself.) Again, blessings on the community for their help. Stephen P. Schaefer "If you are made to wait, it is only to serve you better." - quoted in "The Mythical Man Month" by F. P. Brooks.