bash - Pick files from folder, process, delete -
in linux shell, treat folder bag of files. there processes put files bag. there 1 process in either 1 of 2 following states:
- process document, delete it
- wait arbitrary document exist in folder, process it
it not matter in order documents processed or name is.
what unique process taking files folder likein bash? processing means calling program filename argument.
note unique process not terminate until manually.
you can use incrond
, stands "inotify cron daemon". daemon runs in background , monitors directories specified in table. valid configuration can created with
incrontab -e
this open editor , type in directory , actions want watch, e.g.,
/path/to/observed/directory in_create,in_moved_to <command> $@/$#
<command>
command or script want execute if 1 of events (in_create,in_moved_to
) triggered. $@/$#
path file created or moved watched folder , passed <command>
. need start watching folder.
you have initialize incrond once telling users may use service. can allow users use incrond adding them incrond.allow
, e.g.,
echo 'root' >> /etc/incrond.allow echo '<username>' >> /etc/incrond.allow
notice, root
must in incrond.allow
. can start daemon calling
incrond
more information on incrond
:
Comments
Post a Comment