nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

If file modified execute a script

This is a discussion on If file modified execute a script within the Shell scripting forums, part of the Development/Scripting category; I have some server application running on FC6 but clients loose contact unless they restart client application after server ip ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-11-2006, 04:07 PM
Junior Member
User
 
Join Date: Jun 2006
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
karabaja
Default If file modified execute a script

I have some server application running on FC6 but clients loose contact unless they restart client application after server ip has changed. And it changes once a day I think. I have inadyn running since clients connect to dyndns address but they still can't reconnect unless they restart client tool or I restart server application.
So I was hoping there is a way to run something that would restart server when it notices that inadyn.log file was modified. Since file is modified when it updates to new ip.
Reply With Quote
  #2 (permalink)  
Old 07-11-2006, 12:54 AM
rockdalinux's Avatar
Is that all you got?
User
 
Join Date: May 2005
Location: Planet Vegeta
OS: Redhat
Posts: 708
Thanks: 15
Thanked 19 Times in 18 Posts
Rep Power: 10
rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light
Default

Hmm

You need to store your inadyn.log log file current time somewhere. Then you can monitor current time and compare with stored location. If both differ restart the server.

Logic/script:
Code:
#!/bin/sh
file="/path/to/inadyn.log"
fileatime="/etc/current.time"
a=""
b=""
[ ! -f $fileatime ] && stat $file | grep Modify > $fileatime || :
[ -f $fileatime ] && a="$(cat $fileatime)" || exit 1
b="$(stat $file | grep Modify)"
if [ "$a" != "$b" ]; then
   echo "Restart server...."
   # update time
   stat $file | grep Modify > $fileatime 
fi
__________________
Rocky Jr.
What's wrong? I hope I am not making you uncomfortable...

Never send a boy to do a mans job.
Reply With Quote
  #3 (permalink)  
Old 17-11-2006, 10:58 PM
Junior Member
User
 
Join Date: Jun 2006
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
karabaja
Default

Ok, thx a lot. I just managed to read reply since I kept getting page not found. But I am glad to see you guys sorted it out.
Reply With Quote
  #4 (permalink)  
Old 23-11-2006, 02:39 AM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 244 Times in 183 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Sorry for trouble. It is now sorted out and you should able to use fourm.
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
[Solved] Shell script for ftp the file vishal_titre Shell scripting 4 21-08-2009 03:50 PM
Make file script, need help understanding shaziluk Shell scripting 0 16-09-2007 03:30 AM
script finding file and sorting dementeddude Shell scripting 14 25-07-2006 05:30 PM
script on how to check if the file exists warren Shell scripting 4 14-04-2006 05:51 PM
#why following cannot be execute? ryan Shell scripting 7 16-03-2005 06:50 PM


All times are GMT +5.5. The time now is 04:19 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38