# Is there a file watchdog concept in julia

**URL:** https://discourse.julialang.org/t/is-there-a-file-watchdog-concept-in-julia/74316
**Category:** General Usage
**Created:** [January 10, 2022, 1:02am UTC](https://discourse.julialang.org/t/is-there-a-file-watchdog-concept-in-julia/74316 "2022-01-10T01:02:56Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![anon69491625](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@anon69491625](https://discourse.julialang.org/u/anon69491625)
#### Post date: [January 10, 2022, 1:02am UTC](https://discourse.julialang.org/t/is-there-a-file-watchdog-concept-in-julia/74316/1 "2022-01-10T01:02:56Z")

</div>

Hi All  
I am experimenting with some thoughts about how I want to use julia. One of them is to keep an eye on a directory and watch for interesting events. Some examples

- file creation
- file deletion
- file modification
- file move

An example in python ( not my code) is below. I don’t really want to wrapper it in pycall IF there is a builtin or Pkg that does it already as I am trying to leave python behind.

I have searched around but I can’t seem to find anything. Any pointers would be welcome.

```julia

# https://thepythoncorner.com/posts/2019-01-13-how-to-create-a-watchdog-in-python-to-look-for-filesystem-changes/

import time
from watchdog.observers import Observer
from watchdog.events import PatternMatchingEventHandler

def on_created(event):
    print(f"hey, {event.src_path} has been created!")

def on_deleted(event):
    print(f"what the ! Someone deleted {event.src_path}!")

def on_modified(event):
    print(f"hey buddy, {event.src_path} has been modified")

def on_moved(event):
    print(f"ok ok ok, someone moved {event.src_path} to {event.dest_path}")

if __name__ == " __main__":
    
    patterns = ["*"]
    ignore_patterns = None
    ignore_directories = False
    case_sensitive = True
    
    my_event_handler = PatternMatchingEventHandler(patterns, ignore_patterns, ignore_directories, case_sensitive)

    
    my_event_handler.on_created = on_created
    my_event_handler.on_deleted = on_deleted
    my_event_handler.on_modified = on_modified
    my_event_handler.on_moved = on_moved

    path = "."
    go_recursively = True
    my_observer = Observer()
    my_observer.schedule(my_event_handler, path, recursive=go_recursively)

    
    my_observer.start()
    try:
       while True:
            time.sleep(1)
    except KeyboardInterrupt:
        my_observer.stop()
        my_observer.join()

```

---

<div class="post-metadata">

### Author: ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)
#### Post date: [January 10, 2022, 1:04am UTC](https://discourse.julialang.org/t/is-there-a-file-watchdog-concept-in-julia/74316/2 "2022-01-10T01:04:48Z")

</div>

There is the FileWatching stdlib: [https://docs.julialang.org/en/v1/stdlib/FileWatching/](https://docs.julialang.org/en/v1/stdlib/FileWatching/)

---

<div class="post-metadata">

### Author: ![anon69491625](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@anon69491625](https://discourse.julialang.org/u/anon69491625)
#### Post date: [January 10, 2022, 1:18am UTC](https://discourse.julialang.org/t/is-there-a-file-watchdog-concept-in-julia/74316/3 "2022-01-10T01:18:42Z")

</div>

hey @ericphanson I’ll certainly check that out. I did see it but I rushed past it thinking it was just a file watcher. For some reason, stupidity, I forgot that ALL things in linux are a file… Thanks for the nudge back to the right path.
