monitor_and_run

command module
v0.0.0-...-01aade9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2016 License: MIT Imports: 7 Imported by: 0

README

Monitor and Run

A simple Go program to monitor a file/directory and run a script when something changes (creation, modification, deletion).

Example

The script
#!/usr/bin/env bash
#myscript.sh

# Run make every time something changes.
# Probably not a great idea unless you are watching a single file,
# like your Pandoc-based resume for instance.
make
Monitor something and act on changes

monitor_and_run -script=myscript.sh -directory=resume.md

Now each time you change your resume, myscript.sh will be called, presumably generating PDF, HTML, and other versions of your resume.

More Info

Your script should be idempotent, especially if watching an entire directory.

I wrote this out of an interest in Go and the desire for a straightforward file watcher. There are far more sophiscated (and maintained) solutions available. See this question or try your luck with Google if you have more complex needs. However, this tool solves a problem for me, and it may for you as well. Feel free to use it.

If you find any serious problems, please create an issue. However, if you have feature requests, please take a look at similar programs first, or fork this project and add them. I do not see a need for yet another file watching utility, so I intend to keep this as simple as possible for my use case.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL