How to run a script every time I save a file in Linux?

How do I run a script every time I save a file in Linux?

+3
source share
2 answers

Linux has a subsystem call inotify , which can cause file systems to report changes to the file system in applications.

Your Linux system probably has a package called incronthat makes it easy to use inotify. (Or find available packages for any package whose description contains the word "inotify").

incron cron, , cron script , incron script , .

PS. , Ubuntu incron

sudo apt-get install incron
+10

python script, .

https://github.com/bawigga/spy

:

$ ./spy myscript.py
... your script output ...

$ ./spy --help
Usage: spy [OPTIONS] [WATCH]

Options:
  --version             show program version number and exit
  -h, --help            show this help message and exit
  -c, --clear           clear the screen after each execution
  -e COMMAND, --exec=COMMAND
                        path to the program to execute
  -i INTERVAL, --interval=INTERVAL
                        (in seconds) set the time interval to check for file
                        modifications
0

Source: https://habr.com/ru/post/1702676/


All Articles