Hi

Sorry for the late reply.
My script is working fine now ...

The issue was with file permissions .


Thanks to all  for their help.


Regards
Prajakt




--- On Sun, 9/11/08, Muzaffar Ansari <[EMAIL PROTECTED]> wrote:
From: Muzaffar Ansari <[EMAIL PROTECTED]>
Subject: Re: [LinuxVadaPav] bash script not working in cron job
To: [email protected]
Date: Sunday, 9 November, 2008, 1:22 PM










    
            hi,



can u paste the output of /tmp/ping.err, the file where u r collecting the logs 
of the script final1.sh



also i don't understand y ur script path looks so obscure as '/bin/bash 
/usr/local/sbin/ ping/final1. sh'



 

-----------

Muzaffar Ansari

+91 9224339939 

ansarimuzaffar@ yahoo.com



____________ _________ _________ __

From: linux rocker <linuxrocker009@ yahoo.co. in>

To: linuxvadapav@ yahoogroups. com

Sent: Saturday, November 8, 2008 12:48:13 PM

Subject: [LinuxVadaPav] bash script not working in cron job



Hi



i have written 1 bash script but it is not working in cron job



the script is for checking the status of internet connection from two diff isp 
using ping command



#!/bin/bash

for file in `cat ipaddress`

do

ipAdd=`echo $file | awk -F, '{print $1}'`



curstate=0

pstate=0

case "$ipAdd" in



   1.1.1.1) prevstate=". /mtnl.txt"

   echo "IPADDRESS = $prevstate"

   msg="./isp1_ report.txt" ;;



   2.2.2.2) prevstate=". /netmagic. txt"

   echo "IPADDRESS = $prevstate"

   msg="./isp2_ report.txt" ;;

esac



   curstate=`/bin/ ping -c 1  $ipAdd | grep "100% packet loss" | wc -l`

   echo "current state= $curstate"



for pstate in `cat $prevstate`

do

    echo "previous state==$pstate"

done



if [ $curstate -ne $pstate ] ; then

    echo "status changed" ;

    if [ $curstate -ne 0 ] ; then

    echo "Time: `date`  $ipAdd network failed" >> $msg ;

    else

       echo "Time: `date`  $ipAdd network up" >> $msg ;

    fi echo $curstate > $prevstate

    echo `cat $prevstate`

else

   echo "status remains the same as of previous" ;



fi

echo " "

done



crontab  -l  gives o/p



# /etc/crontab: system-wide crontab

# Unlike any other crontab you don't have to run the `crontab'

# command to install the new version when you edit this file

# and files in /etc/cron.d. These files also have username fields,

# that none of the other crontabs do.



SHELL=/bin/sh

PATH=/usr/local/ sbin:/usr/ local/bin: /sbin:/bin: /usr/sbin: /usr/bin



# m h dom mon dow user    command

17 *    * * *    root    cd / && run-parts --report /etc/cron.hourly

25 6    * * *    root    test -x /usr/sbin/anacron || ( cd / && run-parts 
--report /etc/cron.daily )

47 6    * * 7    root    test -x /usr/sbin/anacron || ( cd / && run-parts 
--report /etc/cron.weekly )

52 6    1 * *    root    test -x /usr/sbin/anacron || ( cd / && run-parts 
--report /etc/cron.monthly )

#



*/10 * * * *    root    /usr/sbin/logrotate /etc/logrotate. conf

*/30 * * * *        /bin/bash /usr/local/sbin/ ping/final1. sh >/tmp/ping.err 
2>&1



Please help me in this issue.



Thanks in advance.



Regards



Prajakt

9967776567

 



Add more friends to your messenger and enjoy! Go to http://messenger. 
yahoo.com/ invite/



[Non-text portions of this message have been removed]



[Non-text portions of this message have been removed]




      

    
    
        
         
        
        








        


        
        


      Add more friends to your messenger and enjoy! Go to 
http://messenger.yahoo.com/invite/

[Non-text portions of this message have been removed]

Reply via email to