0

Im making a bash script which watch for file updating and then execute a function and repeat.

Currently, I use pool method but it may cost system performance and not in-time (depend on the sleep time I set).

So could you suggest any solution? Thanks

Edit: I can not use inotify-tools because Im using company computer, and I can not install anything. So is there any solution by using build-in shell?

Thepro
  • 25
  • 4
  • That's definitely an older duplicate. I like [this answer](http://stackoverflow.com/a/10958125/1072112) too. – ghoti May 04 '17 at 02:12
  • @ghoti Eh, you're biased! ;) – Benjamin W. May 04 '17 at 02:38
  • I admit it! But my duplicate addresses the OP's request for a solution that does not depend on inotify-tools. :) – ghoti May 04 '17 at 02:56
  • @ghoti: thank you for your comment. But I do not have any log file. To understand easily, I have a txt file which everyone can write into, and each time the file is updated, I will take the new data and echo to screen. – Thepro May 04 '17 at 03:40
  • Well, `tail -F` should still detect changes to that file, and you can make triggers based on file growth or rotation. Only catch is that each new write needs to be at the end of the file, and terminate with a newline. – ghoti May 04 '17 at 03:55
  • Oh I got your idea. Basically, I have tried this but there are something I have to process, so I want to watch this file instead of show all update. For ex, if new data is "buzz", this data will not be printed, but a zenity will occur. or if it is ":smile", an icon like :) will appear – Thepro May 04 '17 at 04:16

0 Answers0