fswait: Wait and observe events on the filesystem for a path, with a timeout

[ bsd3, program, tools ] [ Propose Tags ] [ Report a vulnerability ]

fswait is a utility for blocking on the observation of a filesystem event for a path with a timeout.

The primary use-case for this is in system startup scripts that depend on the existence of some file or directory that will be created by another system service or job.


[Skip to Readme]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 1.0.0, 1.1.0
Dependencies base (>=4.8 && <5), hinotify (>=0.3 && <0.4), optparse-applicative (>=0.12 && <0.15), optparse-generic (>=1.2 && <1.3), semigroups (>=0.18 && <0.19), stm (>=2.4.4.1 && <2.5), system-filepath (>=0.3.1 && <0.5), text (>=0.11 && <3), time-units (>=1.0.0 && <2.0), turtle (>=1.3.0 && <1.4) [details]
Tested with ghc ==7.10.2, ghc ==8.0.1
License BSD-3-Clause
Copyright 2017 Parnell Springmeyer
Author Parnell Springmeyer
Maintainer parnell@digitalmentat.com
Revised Revision 1 made by ParnellSpringmeyer at 2023-12-04T16:37:00Z
Category Tools
Home page https://github.com/ixmatus/fswait
Bug tracker https://github.com/ixmatus/fswait/issues
Source repo head: git clone https://github.com/ixmatus/fswait
Uploaded by ParnellSpringmeyer at 2017-06-28T23:09:01Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Executables fswait
Downloads 1596 total (3 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
Last success reported on 2017-06-28 [all 3 reports]

Readme for fswait-1.1.0

[back to package description]

Welcome!

Build Status

fswait is a utility for blocking on the observation of a filesystem event for a path with a timeout.

This is useful when you need to block the execution of a separate program on the creation (or some other filesystem event) of a filepath but you want that block constrained by a timeout.

A common use-case is in systemd services, some daemons may need a socket or some other file to exist before starting and it is common to write shell code to implement that check-and-wait-with-timeout.

This tool makes that pattern more easily expressed as a command line utility call that also supports observing many different filesystem events for the specified path.

$ fswait --path /etc/someconfig.ini --modify --create && echo 'Do something!'
observing Create Modify for /home/parnell/Desktop/test.sh
the window for an observation is 120s
Created {isDirectory = False, filePath = "someconfig.ini"}
Do something!

When an observation occurs, the utility will return immediately with an exit code of 0 and print the observed event.

If the timeout window is reached without an observation occurring, an exit code of 1 is returned.

$ fswait --help
Wait and observe events on the filesystem for a path, with a timeout

Usage: fswait [--timeout Seconds] --path FILEPATH [--exists] (--access |
              --modify | --attrib | --close | --closeWrite | --closeNoWrite |
              --open | --move | --moveIn | --moveOut | --moveSelf | --create |
              --delete | --onlyDir | --noSymlink | --maskAdd | --oneShot |
              --all) ([--access]... | [--modify]... | [--attrib]... |
              [--close]... | [--closeWrite]... | [--closeNoWrite]... |
              [--open]... | [--move]... | [--moveIn]... | [--moveOut]... |
              [--moveSelf]... | [--create]... | [--delete]... | [--onlyDir]... |
              [--noSymlink]... | [--maskAdd]... | [--oneShot]... | [--all]...)

Available options:
  -h,--help                Show this help text
  --timeout Seconds        Window to observe a filesystem event (default: 120s,
                           negative values wait indefinitely)
  --path FILEPATH          Observe filesystem events for path
  --exists                 Return immediately if the filepath already exists

Installing

If you have Nix you can install it using:

$ nix-env --install --attr fswait release.nix