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.

12
  • pyinotify or inotify-tools according to stackoverflow.com/a/12582773/320220 Commented Mar 3, 2015 at 13:02
  • As far as I know there is no inotify for freebsd or is there? Commented Mar 3, 2015 at 13:04
  • changed in which way? Commented Mar 3, 2015 at 13:04
  • 2
    You could try watchdog which claims to support BSD. Commented Mar 3, 2015 at 13:13
  • 1
    There is also entrproject.org Commented Mar 3, 2015 at 13:13

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.