{"id":13587531,"url":"https://github.com/devilbox/watcherd","last_synced_at":"2025-05-12T23:41:59.456Z","repository":{"id":55842857,"uuid":"103753825","full_name":"devilbox/watcherd","owner":"devilbox","description":"A shell daemon that will listen for directory changes and execute custom commands for each event.","archived":false,"fork":false,"pushed_at":"2023-01-03T21:53:17.000Z","size":79,"stargazers_count":54,"open_issues_count":0,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-12T23:41:56.608Z","etag":null,"topics":["inotify","inotifywait","watcher"],"latest_commit_sha":null,"homepage":"http://devilbox.org","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devilbox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-16T13:25:29.000Z","updated_at":"2025-03-16T21:35:53.000Z","dependencies_parsed_at":"2023-02-01T10:46:58.903Z","dependency_job_id":null,"html_url":"https://github.com/devilbox/watcherd","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devilbox%2Fwatcherd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devilbox%2Fwatcherd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devilbox%2Fwatcherd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devilbox%2Fwatcherd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devilbox","download_url":"https://codeload.github.com/devilbox/watcherd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253843170,"owners_count":21972867,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["inotify","inotifywait","watcher"],"created_at":"2024-08-01T15:06:15.266Z","updated_at":"2025-05-12T23:41:59.410Z","avatar_url":"https://github.com/devilbox.png","language":"Shell","readme":"# watcherd\n\n![tag](https://img.shields.io/github/v/tag/devilbox/watcherd.svg?colorB=orange\u0026sort=semver)\n[![linting](https://github.com/devilbox/watcherd/workflows/linting/badge.svg)](https://github.com/devilbox/watcherd/actions/workflows/linting.yml)\n[![test-linux](https://github.com/devilbox/watcherd/workflows/test-linux/badge.svg)](https://github.com/devilbox/watcherd/actions/workflows/test-linux.yml)\n[![test-macos](https://github.com/devilbox/watcherd/workflows/test-macos/badge.svg)](https://github.com/devilbox/watcherd/actions/workflows/test-macos.yml)\n[![test-windows](https://github.com/devilbox/watcherd/workflows/test-windows/badge.svg)](https://github.com/devilbox/watcherd/actions/workflows/test-windows.yml)\n[![License](https://img.shields.io/badge/license-MIT-%233DA639.svg)](https://opensource.org/licenses/MIT)\n\n\n**[watcherd](https://github.com/devilbox/watcherd/blob/master/bin/watcherd)** will look for directory changes (added and deleted directories) under the specified path (`-p`) and will execute specified commands or shell scripts (`-a`, `-d`) depending on the event.\nOnce all events have happened during one round (`-i`), a trigger command can be executed (`-t`).\nNote, the trigger command will only be execute when at least one add or delete command has succeeded with exit code 0.\n\n---\n\nIf you need the same functionality to monitor changes of listening ports, check out **[watcherp](https://github.com/devilbox/watcherp)**.\n\n---\n\n### Modes\n\n**[watcherd](https://github.com/devilbox/watcherd/blob/master/bin/watcherd)** can either use the native [inotifywait](https://linux.die.net/man/1/inotifywait) implementation or if this is not available on your system use a custom bash implementation. The default is to use bash.\n\n### Placeholders\n\nThere are two placeholders available that make it easier to use custom commands/scripts for the add (`-a`) or delete (`-d`) action.:\n\n* `%p` Full path to the directory that was added or deletd\n* `%n` Name of the directory that was added or deleted\n\nYou can specify the placeholders as many times as you want. See the following example section for usage.\n\n### Examples\n\nBy using **[vhost-gen](https://github.com/devilbox/vhost-gen)** (which is capable of creating Nginx or Apache vhost config files for normal vhosts or reverse proxies), the following will be able to create new nginx vhosts on-the-fly, simply by adding or deleting folders in your main www directory. The trigger command will simply force nginx to reload its configuration after directory changes occured.\n\n```shell\n# %n will be replaced by watcherd with the new directory name\n# %p will be replaced by watcherd with the new directory path\nwatcherd -v \\\n  -p /shared/httpd \\\n  -a \"vhost-gen -p %p -n %n -s\" \\\n  -d \"rm /etc/nginx/conf.d/%n.conf\" \\\n  -t \"nginx -s reload\"\n```\n\n### Usage\n\n```bash\nUsage: watcherd -p \u003cpath\u003e -a \u003ccmd\u003e -d \u003ccmd\u003e [-t \u003ccmd\u003e -w \u003cstr\u003e -i \u003cint\u003e -v -c]\n       watcherd --help\n       watcherd --version\n\nwatcherd will look for directory changes (added and deleted directories) under\nthe specified path (-p) and will execute specified commands or shell scripts\n(-a, -d) depending on the event. Once all events have happened during one round\n(-i), a trigger command can be executed (-t). Note, the trigger command will\nonly be execute when at least one add or delete command has succeeded with exit\ncode 0.\n\nRequired arguments:\n  -p \u003cpath\u003e     Path to directoy to watch for changes.\n  -a \u003ccmd\u003e      Command to execute when a directory was added.\n                You can also append the following placeholders to your command string:\n                %p The full path of the directory that changed (added, deleted).\n                %n The name of the directory that changed (added, deleted).\n                Example: -a \"script.sh -f %p -c %n -a %p\"\n  -d \u003ccmd\u003e      Command to execute when a directory was deletd.\n                You can also append the following placeholders to your command string:\n                %p The full path of the directory that changed (added, deleted).\n                %n The name of the directory that changed (added, deleted).\n                Example: -d \"script.sh -f %p -c %n -a %p\"\n\nOptional arguments:\n  -e \u003cregex\u003e    Exclude regex for directories to ignore.\n                E.g.: -e '\\.*' to ignore dot directories.\n  -t \u003ccmd\u003e      Command to execute after all directories have been added or\n                deleted during one round.\n                No argument will be appended.\n  -w \u003cstr\u003e      The directory watcher to use. Valid values are:\n                'inotify': Uses inotifywait to watch for directory changes.\n                'bash':    Uses a bash loop to watch for directory changes.\n                The default is to use 'bash' as the watcher.\n  -i \u003cint\u003e      When using the bash watcher, specify the interval in seconds\n                for how often to look for directory changes.\n  -v            Verbose output.\n  -c            Colorized log output.\n\nMisc arguments:\n  --help        Show this help screen.\n  --version     Show version information.\n```\n\n### License\n\n**[MIT License](LICENSE)**\n\nCopyright (c) 2017 [cytopia](https://github.com/cytopia)\n","funding_links":[],"categories":["Shell"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevilbox%2Fwatcherd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevilbox%2Fwatcherd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevilbox%2Fwatcherd/lists"}