Re: Can't capture PID with script in cron

From: Bit Twister (BitTwister_at_localhost.localdomain)
Date: 11/10/03

  • Next message: walala: "is there anyway to do easy setup for ssh password free logon?"
    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.


  • Next message: walala: "is there anyway to do easy setup for ssh password free logon?"

    Relevant Pages

    • Re: Script for daily quit not working ... thoughts?
      ... Have you tried re-recording the script? ... So I created an AppleScript: ... > tell application "Microsoft Entourage" ... > But Entourage won't really quit. ...
      (microsoft.public.mac.office.entourage)
    • Re: Script for daily quit not working ... thoughts?
      ... The only difference I would make would be to save the script as a compiled ... Seen the All-New Entourage Help Pages? ... Script for daily quit not working ... ... So I created an AppleScript: ...
      (microsoft.public.mac.office.entourage)
    • Re: Netcat question
      ... Also, I apologize since I think you might have provided this already, but can we see the virtual device script? ... Maybe a quick & dirty hack fix is to have the virtual device script always append something unobtrusive to the collected print data for no other reason than to garuntee that the print jobs are always at least a few bytes. ... It uses a cheap-o single port print server that snaps onto the centronics plug just like that netgear ps101. ...
      (comp.unix.sco.misc)
    • Re: Netcat question
      ... If you write the virtual device script to simply throw out all output from ... than to garuntee that the print jobs are always at least a few bytes. ... It uses a cheap-o single port print server that snaps onto the centronics ...
      (comp.unix.sco.misc)
    • Re: Time Machine: Spit!!!
      ... I'd like a script that'd dive down a directory tree recursively and move ... If you want to see an AppleScript version as well then I could knock one up in the next day or so when I have a bit of spare time. ... As for data types - I just develop patiently one small bit at a time and looking carefully at the results. ... Standard way to do recursion in AppleScript is to define a function that calls itself. ...
      (uk.comp.sys.mac)