Find the answer to your Linux question:
Results 1 to 2 of 2
The program below is supposed to check which scripts are running against those listed in a text file. On each loop it should write to the log file stating if ...
  1. #1
    Just Joined!
    Join Date
    Aug 2008
    Posts
    1

    Check for running scripts

    The program below is supposed to check which scripts are running against those listed in a text file. On each loop it should write to the log file stating if the program is running or not. The problem is that if a script is not running but is in the AllScripts.txt file nothing happens.

    How do I fix this?


    scriptchecker.sh
    Code:
    #!/sbin/sh -
    log() {
        /usr/bin/echo "$1" >> ${LOGFILE}
    }
    LOGFILE=/var/tmp/Paul/scripts/chk_scripts.log
    while true
    do
    	ps -efa | awk '/[c]hk/ { print (substr($0, 58)) }' |
    	while read line
    	do
    		if fgrep "$line" /var/tmp/Paul/scripts/AllScripts.txt
    		then
    			log "$line running"
    		else	
    			log "$line not running"
    			#echo "$line not running!!!!" | /usr/lib/sendmail paul.anthony.carron@citi.com
    		fi
    	done
    	sleep 30
    done
    AllScripts.txt
    Code:
    /var/opt/live/scripts/chk_log.sh
    /var/opt/live/scripts/chk_pending.sh
    /var/opt/live/scripts/chk_process.sh
    /var/opt/live/scripts/chk_tawt.sh

  2. #2
    Linux Newbie
    Join Date
    Jul 2008
    Posts
    181
    This script is obviously brittle, and I think you might mean 48 and not 58.

Posting Permissions

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