https://github.com/tomnomnom/symwatch
A tool to run a command when the target of a symlink changes
https://github.com/tomnomnom/symwatch
Last synced: 9 months ago
JSON representation
A tool to run a command when the target of a symlink changes
- Host: GitHub
- URL: https://github.com/tomnomnom/symwatch
- Owner: tomnomnom
- License: mit
- Created: 2016-04-27T14:53:18.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-04-28T23:46:58.000Z (about 10 years ago)
- Last Synced: 2025-09-07T06:36:02.715Z (9 months ago)
- Language: Go
- Size: 9.77 KB
- Stars: 16
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.mkd
- Changelog: CHANGELOG.mkd
- Contributing: CONTRIBUTING.mkd
- License: LICENSE
Awesome Lists containing this project
README
# symwatch
Watches a symlink and runs a command when the target of the symlink changes.
[](https://travis-ci.org/tomnomnom/symwatch)
## Installation
```
go get github.com/tomnomnom/symwatch
```
## Usage
```
Usage:
symwatch []
Options:
symlink An absolute or relative path to a symlink
command The command to run when the symlink target changes
pollInterval The number of milliseconds to wait between polling the symlink (default 500)
Notes:
* If the symlink is unreadable for more than 5 attempts the process will exit
* Commands are passed to `sh -c`
Exit Codes:
0 OK
1 Invalid Arguments
2 Invalid Symlink
3 Symlink Went Away
Example:
symwatch /var/www/current 'service apache2 graceful' 500
```
## Motivation
It's a fairly common pattern to use a symlink to point to the current version of
a codebase. Sometimes it's neccesary to restart processes or clear caches when the version
of a codebase changes.
## Why not use inotify?
It's not portable. In particular it does not work if the symlink being polled is on an NFS share.