1

I want to run a little python script on my Freenas inside a Jail.

The script should watch out for a file. If this file is changed. It should do something.

So my question is what is the mechanism which allows me to monitor a file and run a method when the file is changed (In detail the content of one specific file) or is there another method to just call a python script in such a case.

TM90
  • 640
  • 6
  • 17

1 Answers1

2

That's job for kqueue. There are 2 possible bindigs for that... py-kqueue (all BSDs and OSX) and py-freebsd (just FreeBSD). Both in ports. Some hint how to use kqueue here: Check if file is modified deleted or extended using python select.kqueue()

Other example to understand kqueue in py-openbsd bindings docs: kqueue - openbsd. And then of course man kqueue.

Further option is to use Twisted async framework (which in background will use kqueue for reactor) and its FileMonitoringService. This is periodic checker, generic implementation - OS agnostic.

Community
  • 1
  • 1
nudzo
  • 12,086
  • 2
  • 15
  • 18