Run a shell command when a file is added

前端 未结 6 537
梦毁少年i
梦毁少年i 2020-11-27 20:04

I have a folder named images on my linux box. This folder is connected to a website and the admin of the site has the ability to add pictures to this site. However, when a

6条回答
  •  天涯浪人
    2020-11-27 20:29

    Like John commented the inotify API is a starting point, however you might be interested in some tools that use this API to perform file notification tasks:

    For example incron which can be used to run cron-like tasks when file or directory changes are detected.

    Or inotify-tools which is a set of command-line tools that you could use to build your own file notification shell script.

    If you look at the bottom of the Wiki pake for inotify-tools you will see references to even more tools and support for higher-level languages like Python, Perl or Ruby (example code).

提交回复
热议问题