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 ...
- 08-20-2008 #1Just 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
AllScripts.txtCode:#!/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
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
- 08-20-2008 #2Linux Newbie
- Join Date
- Jul 2008
- Posts
- 181
This script is obviously brittle, and I think you might mean 48 and not 58.


Reply With Quote