简体   繁体   中英

Trigger a java jar file when a file is modified in the Linux headless machine

I need to trigger a java jar file whenever a file ( report.html ) is updated in linux headless machine.

java -jar readReport.jar

How do I do this?

Thanks in advance.

As I am new to Linux just gave a try with inotifywait, please check if this is correct

#!/bin/sh
while inotifywait -e modify <path-to-report.html> 
do
  java -jar readReport.jar
done

Will this check continuously for the update in a loop and whenever there is an update of (report.html) this jar has to be executed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM