Hi dspence
... If you need help with that, I can provide a sample of how I
used inotifywait to trigger a command when a file gets created. ...
I decide to create a script that does what I described in my previous post.
The script is called WatchDirectory.sh
tc@E310:~/Scripting/WatchDirectory$ ls -l
total 4
-rwxrwxr-x 1 tc staff 2929 Jul 4 11:26 WatchDirectory.shThe scripts variable Dir1 tells it which directory to monitor.
Dir1="/home/tc/Scripting/WatchDirectory/"Full paths are recommended.
Here I launch the script in the background and create 4 files.
tc@E310:~/Scripting/WatchDirectory$ ./WatchDirectory.sh &
tc@E310:~/Scripting/WatchDirectory$ touch File1 File2 File3 File4
tc@E310:~/Scripting/WatchDirectory$ ls -l
total 8
drwxr-sr-x 2 tc staff 4096 Jul 4 13:20 Dmesg/
-rw-r--r-- 1 tc staff 0 Jul 4 13:20 File1
-rw-r--r-- 1 tc staff 0 Jul 4 13:20 File2
-rw-r--r-- 1 tc staff 0 Jul 4 13:20 File3
-rw-r--r-- 1 tc staff 0 Jul 4 13:20 File4
-rwxrwxr-x 1 tc staff 2927 Jul 4 13:19 WatchDirectory.shHere you see the script created a separate Dmesg directory for storing
all dmesg dumps plus the 4 files I created.
Here is the result in the Dmesg directory:
tc@E310:~/Scripting/WatchDirectory$ ls -l Dmesg/
total 336
-rw-r--r-- 1 tc staff 83270 Jul 4 13:20 File1-2026-07-04-13:20:00.Dmesg
-rw-r--r-- 1 tc staff 83270 Jul 4 13:20 File2-2026-07-04-13:20:05.Dmesg
-rw-r--r-- 1 tc staff 83270 Jul 4 13:20 File3-2026-07-04-13:20:10.Dmesg
-rw-r--r-- 1 tc staff 83270 Jul 4 13:20 File4-2026-07-04-13:20:15.DmesgThe dmesg file names are in the form of:
CreatedFileName-TimeStamp.DmesgThat should simplify matching the dmesg to the core dump that triggered it.
Also, you'll notice a 5 second delay in the time stamps. I allow 5 seconds
between detecting the core dump and creating the dmesg file in case the
core dump needs time to finish writing.
As set up, the script monitors 1 directory, though it could monitor more.
It acts on file creation and ignores directory creation.
It will only monitor directories pointed to (no recursion).
The basic purpose of this script to monitor a directory and run commands
when a new file is created. It is fairly well commented. As such it should
be fairly simple to repurpose if anybody wishes to.
A copy is attached to the end of this post.