Linux uses inotify-tools's inotifywait implementation: When the folder content changes, a script is automatically executed. When I create an rpm package management server, this requirement exists, when a new rpm is stored in a specified directory, a script is automatically executed to check the rpm package. The inotifywait module of inotify-tools is used here. There is an event processing parameter-e, which can be found in its Manual. My code is as follows: [python] #/bin/bash ################################ ################################# automatically run a script (action. sh) when the contents # of a directory ($ {EVENTPATH}) changed. # pls. install the inotify-tools-3.13-1.el4.rf.i386.rpm module # before use this scripts # Aborn Jiang (aborn.jiang@gmail.com) # Sep.8, 2013 ####################################### ######################### EV ENTPATH = ". "MSG = ". inotifymsg "PATTERN = ". rpm $ "# only when the rpm files changed. while inotifywait-e modify-e create-e delete-e moved_to-e moved_from \$ {EVENTPATH} 1 >1 {EVENTPATH}/$ {MSG} 2>/dev/null; do FILE = 'cat $ EVENTPATH/$ {MSG} | egrep $ {PATTERN} | awk '{print $3}' 'Action = 'cat $ EVENTPATH/$ {MSG} | egrep $ {PATTERN} | awk '{print $2 }''[! -Z $ {FILE}] & \ echo "in the directory $ {EVENTPATH}, the file :$ {FILE} modified, action :$ {ACTION }"&&\. /action. sh done I only want to check whether there is any rpm change here. You can modify the PATTERN variable content in the code to detect any file! If you want to detect any file, you can set PATTERN to "*" and put the execution script in action. sh.