Re: Can't capture PID with script in cron
From: Bit Twister (BitTwister_at_localhost.localdomain)
Date: 11/10/03
- Previous message: spacemancw: "Re: Can't capture PID with script in cron"
- In reply to: spacemancw: "Re: Can't capture PID with script in cron"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 10 Nov 2003 20:04:38 GMT
On 10 Nov 2003 10:42:18 -0800, spacemancw wrote:
Glad to see you have quit top posting and started responding after the
point(s) in question. :)
Some people just hate that.
> It's a very simple script ....
> More the reason to get frustrated when something small just doesn't
> work .....
Been there done that. I have had more problems with little programs
than with much larger programs.
> Works now tho
>
> #!/bin/sh
Noticed you hardcoded paths to programs. That was part of the env
hints given. I had visions of you setting every thing you found in
your environment and that kludge hid the fact that you also set the
$PATH var. What you can do is add something like
. /etc/profile # set PATH and LD_LIBARY and what not env vars
That will make the script a little more portable to other systems
> DATE=`date`
I had wondered if date was working without /bin/date,
you never said. Guess MAC OS works different, than I thought, in cron.
The other things you might keep in mind are the following general
rules for cron/at/batch jobs:
o cron/at batch jobs are not hooked to a tty. So, dinking with term and
doing terminal commands can cause problems.
o For debugging you can use the set -x or set -vx or #!/bin/sh -x
so you not have to go through the pain of adding/deleting the
debugging code like the echo suggestion I gave.
o You can create a cron_test scrit which can pipe/tee or redirect your
script output under test.
#!/bin/sh
/where/ever/icall | tee /tmp/cron_test.log
or
/where/ever/icall > /tmp/cron_test.log 2>&1
o User's .cshrc/.kshrc/.bash_* are not normally executed in cron.
o if applications support it, always test return codes or add
additional code. That helps tell you what the problem is when the
script fails a few months in the future because of a full disk,
protection on output files are incorrect, missing/wrong runtime
library, . . . .
Example:
touch /Users/myhome/icallog.txt
if [ $? -ne 0 ] ; then
echo "Error touching /Users/myhome/icallog.txt"
exit 1
fi
echo "iCal restart with PID of $PID" >> /Users/myhome/icallog.txt
/Users/myhome/AS/ical.app
Now if /Users is not mounted the touch error message will get you
closer to the problem than wondering why /Users/myhome/AS/ical.app
has not done it's job.
I use indented flower boxes for comments to make it easier to find the code.
#********************************************************************
# ical.app is an applescript and applescripts can be launched at
# the command line with just the path to the app.
# The applescript performs a function in the Mac OS scripting language
# and then quits iCal
#********************************************************************
/Users/myhome/AS/ical.app
exit
Happy scripting.
- Previous message: spacemancw: "Re: Can't capture PID with script in cron"
- In reply to: spacemancw: "Re: Can't capture PID with script in cron"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|