The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
perl script - adding restart logic zedex Shell Programming and Scripting 4 07-08-2008 01:11 PM
need help: shell script to restart apache when no. of processes keeps growing _joshua_ Shell Programming and Scripting 14 03-07-2007 08:06 AM
Restart Script chapmana UNIX for Dummies Questions & Answers 1 11-27-2006 11:21 AM
suspend/restart a process in shell script daneensign Shell Programming and Scripting 1 02-14-2006 12:43 AM
How to restart a script from the top indo1144 Shell Programming and Scripting 2 07-02-2002 07:40 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-02-2009
Bakes Bakes is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 12
Restart script based on MD5sum

Ok, I run a small script, that restarts a perl script when it fails (it's a very unreliable perl script, but I can't change it, it's crucial, and I don't know perl)
It outputs data into a logfile. Unfortunately, it also regularly hangs. This is a major problem because if it hangs, no data is written to the logfile (which is parsed by a python script). So, what I want to do, is to MD5sum the logfile every 30 seconds, and if the md5sum is the same as the md5sum the half minute before, to restart the script. How might I do this?
  #2 (permalink)  
Old 01-02-2009
JerryHone JerryHone is offline
Registered User
  
 

Join Date: Nov 2006
Location: UK
Posts: 178
In Korn...

while true
do
chksum1=`sum <logfile>`
sleep 30
chksum2=`sum <logfile>`
if [ $chksum1 = $chksum2 ]
then
bounce Perl script
fi
done

HTH

Jerry
  #3 (permalink)  
Old 01-02-2009
Bakes Bakes is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 12
I tried this in Korn, and got:
Code:
./checksumtester[10]: [: (path to log):unknown operator
I had the same result when I tried it in Dash as well.
  #4 (permalink)  
Old 01-02-2009
Bakes Bakes is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 12
by the way, line 10 is:
if [ $chksum1 = $chksum2 ]
  #5 (permalink)  
Old 01-02-2009
JerryHone JerryHone is offline
Registered User
  
 

Join Date: Nov 2006
Location: UK
Posts: 178
Have you used single quotes (') instead of backquotes (`) in the "chksum=" lines?
  #6 (permalink)  
Old 01-02-2009
JerryHone JerryHone is offline
Registered User
  
 

Join Date: Nov 2006
Location: UK
Posts: 178
Also, you may want to use...

if [ "$chksum1" = "$chksum2" ]

for correctness and also to protect against embedded spaces in chksum1 and 2.
  #7 (permalink)  
Old 01-02-2009
Bakes Bakes is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 12
I'd actually just copied what you wrote.

It was the "$chksum1" quotes that fixed it. Thanks!
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 11:01 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0