how to achieve linux's inotify-tools shell methods on osx

后端 未结 3 461
小蘑菇
小蘑菇 2020-12-30 12:13

To monitor a file in linux, I can use inotify-tools like this

#!/bin/bash

# with inotify-tools installed, watch for modification of file passed as first par         


        
3条回答
  •  佛祖请我去吃肉
    2020-12-30 13:04

    If you want to wrap this into a Python script, you can use Watchdog, which works with both Linux and OSX.

    https://pypi.python.org/pypi/watchdog

    Here is what it looks like to replace pyinotify with watchdog:

    https://github.com/raphdg/baboon/commit/2c115da63dac16d0fbdc9b45067d0ab0960143ed

    Watchdog also has a shell utility called watchmedo:

    watchmedo shell-command \
        --patterns="*.py;*.txt" \
        --recursive \
        --command='echo "${watch_src_path}"' \
        .
    

提交回复
热议问题