2

I have a Linux command line program.

It produces output to a file.

The output file is modified continuously by the program after short time intervals.

Every time, the program changes the file, I want to be notified.

Is there any command line for that, or any script which could help me?

serenesat
  • 4,611
  • 10
  • 37
  • 53
Shan
  • 18,563
  • 39
  • 97
  • 132
  • "some processing". Makes your question ambiguous. Please correct. – Aditya Feb 13 '14 at 13:14
  • using inotifywait: https://github.com/rvoicilas/inotify-tools/wiki or look http://stackoverflow.com/questions/2972765/linux-script-that-monitors-file-changes-within-folders-like-autospec-does – Jayesh Bhoi Feb 13 '14 at 13:30

2 Answers2

1

I think icrond is what you need

The incrond (inotify cron daemon) is a daemon which monitors filesystem events (such as add a new file, delete a file and so on) and executes commands or shell scripts. It’s use is generally similar to cron.

Take a look here for some examples http://www.cyberciti.biz/faq/linux-inotify-examples-to-replicate-directories/

gino pilotino
  • 852
  • 1
  • 5
  • 7
1

I think you need

Linux: inotify or

File Alteration monitor or

incron or

Linux audit

Also please look here

Also for script you might need as follows using inotify tool.

while true; do
  change=$(inotifywait -e close_write,moved_to,create .)
  change=${change#./ * }
  if [ "$change" = "myfile" ]
  then 
      echo -e "my file changed"
    fi
done
Community
  • 1
  • 1
Jayesh Bhoi
  • 24,694
  • 15
  • 58
  • 73