Table of Contents
dirscan - starts and monitors a collection of processes managing entries
in a directory
dirscan [-m] [-d directory] [-D directory] [-I includestring]
[-X excludestring] path/to/command [arg(s)]
dirscan starts one path/to/command process for each file, dir
or other dir entries of the current directory, up to a limit of 20 processes.
It does this by executing path/to/command [arg(s)] FILE for each dir entry
FILE. dirscan skips directory entries starting with dots.
Every two seconds,
dirscan checks for dir entries again. If it sees new entries, it starts
a new path/to/command process for the next entry in aphabetical order. If
it sees a dir entry where a process has exited, it restarts the process.
dirscan is designed to run forever. If it has trouble on vfork() or running
path/to/command it prints a message to stderr; it will try again five seconds
later.
dirscan does not need a configuration file or resource config. The
usage of Dan Bernstein’s daemontools is strongly recommended.
dirscan has
a small memory footprint and uses low resources. Compiled with dietlibc
and sstripped its size is below 3 KB. Unlike other tools which are 20 times
as big as dirscan it does not use faulty threaded code.
- -m
- use modification
time order instead of alphabetical order, files with equal mtime will be
ordered alphabetically
- -d directory
- change to directory before reading
dir entries
- -D directory
- change to directory before exec’uting child. Do
not execute child if changing dir failed.
- -I includestring
- only process
dir entries with filenames containing includestring
- -X excludestring
- only
process dir entries with filenames not containing excludestring
svscan(8)
,
supervise(8)
http://cr.yp.to/daemontools.html
This example shows
the substitution of NPCD in bulk mode of pnp4nagios:
$ dirscan -m -d var/perfspool
/usr/bin/perl process_perfdata.pl
Automatically compress all files moved into a directory:
$ dirscan -d
zipped -X .gz /bin/gzip -9
Ordering by modification time can only
be done up to a resolution of one second due to "time_t st_mtime" of struct
stat.
dirscan should be run under supervise(8)
control of the daemontools (http://cr.yp.to/daemontools.html)
because of reliability and security reasons like dropping rights when using
supervise and daemontools.
Frank Bergmann, http://www.tuxad.com
Table of Contents