Skip to content

Instantly share code, notes, and snippets.

@mortn
Created June 12, 2014 21:32
Show Gist options
  • Save mortn/91a6a94913ba433c478f to your computer and use it in GitHub Desktop.
Save mortn/91a6a94913ba433c478f to your computer and use it in GitHub Desktop.
pyinotify example for watching DHCP leases file
import pyinotify,subprocess
def onChange(ev):
cmd = ['/bin/echo', 'File', ev.pathname, 'changed']
subprocess.Popen(cmd).communicate()
wm = pyinotify.WatchManager()
wm.add_watch('/var/lib/dhcp/dhcpd.leases', pyinotify.IN_MODIFY, onChange)
notifier = pyinotify.Notifier(wm)
notifier.loop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment