Home > OS >  Monitor the specified folder file content if there is a change, if there are changes to perform a co
Monitor the specified folder file content if there is a change, if there are changes to perform a co

Time:11-25

Monitor the specified folder file content if there is a change, if there are changes to perform a command

CodePudding user response:

 FILE_THIS="/var/TMP/this. TXT" 
FILE_LAST="/var/TMP/last. TXT"
FOLDER="/var/TMP/aaa/"

While:; Do
If [-e "$FILE_THIS"]; Then
"$FILE_THIS" mv "$FILE_LAST
"Ls "$FOLDER" & gt; "$FILE_THIS
""$FILE_THIS" diff "$FILE_LAST
"If [$?==0]; Then
Echo the Not changed
The else
Echo Changed
Fi
The else
Ls "$FOLDER" & gt; "$FILE_THIS
"Fi
# can be changed by adjusting the time to sleep monitoring frequency
Sleep 5
The done

CodePudding user response:

. You can learn more about the file monitor
Way
  • Related