Results 1 to 6 of 6

Thread: Tracert crontab script

  1. #1
    Join Date
    Dec 2007
    Beans
    18

    Tracert crontab script

    Hi Everyone,

    I am curently building a script to do some tracert to verify if our web hits goes by the 10MB link and not our T1...

    To do so I have devided to use tracert this way :

    > /usr/local/nagios/var/tracert.log
    date >> /usr/local/nagios/var/tracert.log

    sudo /usr/sbin/traceroute EXTERNAL_IP >> /usr/local/nagios/var/tracert.log

    sleep 10


    var=`egrep EXTERNAL_IP.xx? /usr/local/nagios/var/tracert.log | cut -d" " -f4 | cut -d"." -f4`

    if [[( $var = 11 )]]
    then
    mail -s 'We are using the 10 MB link everything is ok' user@domain.com < /usr/local/nagios/var/route_ok.msg
    fi

    if [[( $var = 12 )]]
    then
    mail -s 'Crap ! the 10 MB Link is Down... RUN !' user@domain.com < /usr/local/nagios/var/route_bad.msg
    fi
    So my problem is that tracert need to be run as root and if I try to add this script in another user crontab file, the script does not run...

    What should I do ?

    P.S: Replace the term EXTERNAL_IP by a IP address...
    Last edited by yield999; November 21st, 2008 at 09:03 PM.

  2. #2
    Join Date
    Aug 2008
    Location
    Victoria, BC Canada
    Beans
    1,617

    Re: Tracert crontab script

    Is the script permission for executable set?


    SERVER: Azure datacenters, Hyper-V

  3. #3
    Join Date
    Dec 2007
    Beans
    18

    Re: Tracert crontab script

    Yes and the script run fine if I do
    ./tracert.sh <--- name of my script
    while log as root....

  4. #4
    Join Date
    Mar 2008
    Beans
    4,715
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Tracert crontab script

    Have you tried putting
    Code:
    17 *	* * *	root    /absolute/path/to/tracert.sh
    in /etc/crontab ?
    (Change the path to tracert.sh, of course).

  5. #5
    Join Date
    Dec 2007
    Location
    Buenos Aires, Argentina
    Beans
    1,231
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Tracert crontab script

    Quote Originally Posted by unutbu View Post
    Have you tried putting
    Code:
    17 *	* * *	root    /absolute/path/to/tracert.sh
    in /etc/crontab ?
    (Change the path to tracert.sh, of course).
    ++
    Another one, add the full path to the interpreter you are using, be it bash or sh, before the full path to the script itself:

    Code:
    17 *	* * *	root    /bin/sh /absolute/path/to/tracert.sh
    Live long and prosper.
    And use lotsa Linux, BSD, and Emacs.

  6. #6
    Join Date
    Dec 2007
    Beans
    18

    Re: Tracert crontab script

    The problem was the interpreter....
    It is now fixed.... Thanks guy's... Even if I figure out before I read your reply... lol

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •