1

I have a file called alarm.log, and I want a script to automatically run when this file is changed.

1
  • your-script < tail -f alarm.log Commented Oct 7, 2016 at 9:26

2 Answers 2

1

You should check out inotify, specifically inotyfywait (man page here).

Basic usage:

while inotifywait -e modify alarm.log; do <myScript>; done

There are plenty of good examples of usage in this thread.

1
  • I have a file script who ping host and when to someone host has packet lost write in log file. Commented Oct 19, 2016 at 9:24
1

If you are running systemd, check out systemd.path . Systemd path units use inotify internally, but by using a systemd unit you get a service that is running in the background independently of your login session.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.