crontab vs. links in /etc/cron.hourly (etc.)
David Kramer
david at thekramers.net
Tue Jun 4 21:32:45 EDT 2002
On Tue, 4 Jun 2002, Scott Prive wrote:
> Hello,
>
> Could someone tell me why, if I create a crontab entry for my script (or
> run it manually), it will work OK... but it will not run properly if
> called via a symlink in /etc/cron.hourly.
>
> I chose not to post my script so as to not cloud the issue -- I have a
> solution.
>
> To rephrase, I'm asking why something running as root would behave
> differently than if called via a symlink in /etc/cron.whatever.
It's almost certainly an environment variable issue, or a group issue, if
you are saying you can log in (not just su) as root, and it runs fine,
but it does not when you run it via cron.
My almost-always-works debugging technique for shell scripts is:
turn on -xv to show lines as they are read and as they are executed.
You can do this by:
- Putting -xv at the end of the #!, like #!/bin/sh -xv
- Running the script as "sh -xv myscript,sh"
- putting "set -xv" inside the script. You can turn debugging off again
with "set +xv" (yes, it's backwards).
When you do this, every line will print as its read, and as it's executed
(it will be prepended with a plus sign), complete with all variable
substitutions, so you can really see what's happening.
Also, you know that /etc/crontab is a different format, right?
-------------------------------------------------------------------
DDDD David Kramer http://thekramers.net
DK KD "The Hitchhiker's Guide to the Galaxy also mentions alcohol.
DKK D It says that the best drink in existance is the Pan Galactic
DK KD Gargle Blaster."
DDDD Douglas Adams, "Hitchhiker's Guide to the Galaxy".
More information about the Discuss
mailing list