Home Forums OS X Server and Client Discussion Questions and Answers Sript not working from the crontab

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #376601
    ohmer
    Participant

    Hello,

    I’m trying to make this script working on a OSX 10.4 box.

    [code]#!/bin/bash

    VERIF=`ps aux | grep someapp.app | grep -v grep | wc -l`
    #VERIF=`ps aux | grep someapp.app`

    if [ $VERIF -eq 0 ]
    then
    echo “App restart ..\n\n$VERIF” | mail -s “App restart on $HOSTNAME” [email protected]
    open /Applications/someapp.app
    fi
    [/code]

    This script works when I call it manually but $VERIF return nothing when it’s called from the crontab (so the condition always returns true). I often use this kind of scripts on Linux box without any problems…

    Any idea what’s wrong with this little script ?

    Thanks !

    #376602
    purpanther
    Participant

    Just a sanity check – what does your crontab entry look like?

    something like:

    [code]0 0 * * * sh /usr/local/bin/my_script.sh[/code]

    #376603
    ohmer
    Participant

    In /etc/crontab:

    */30 * * * * admin /usr/local/bin/checkAutomate.sh

    Script have execute permission for all users.

    #376640
    purpanther
    Participant

    I think you need to have “sh” in front of /usr/local/bin/checkAutomate.sh …

    #376641
    ohmer
    Participant

    [QUOTE][u]Quote by: purpanther[/u][p]I think you need to have “sh” in front of /usr/local/bin/checkAutomate.sh …[/p][/QUOTE]

    Doesn’t change anything.

    #377029
    tlarkin
    Participant

    I know this is old, but have launchd run it instead of crontab. Crontab is depreciated now and launchd pretty much controls all daemons from 10.4 and higher.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Comments are closed