MyNixOS website logo
Description

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

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.

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
Metadata

Version

1.1.0

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows