Trigger based on new file in a directory

aujames

Member
Jan 5, 2005
35
0
61
Does anybody know of a method to monitor a directory, and if a file lands in that directory kick off a script? I would like to avoid using cron if possible, and make the file arrival the trigger a action rather than cron running a script to process the file.

Thanks,
JD
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
You'll need to modify the script to use inotify to watch the target directory.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
inotify is pretty neat. I keep meaning to play with it a bit more...

OSSEC has support for it, but my current linux install doesn't. :p
 

xSauronx

Lifer
Jul 14, 2000
19,582
4
81
Originally posted by: n0cmonkey
Originally posted by: Nothinman
OSSEC has support for it, but my current linux install doesn't.

Inotify's been in the Linux kernel for over 4 years now...

Ok, so "current" was the wrong word. ;)

dayum

reminds me of the guy i worked with a couple of years ago who was responsible for keeping up the VOIP company's SIP server or something. he was running it on a fedora core 3 box when at least 7 was the current release.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: xSauronx
Originally posted by: n0cmonkey
Originally posted by: Nothinman
OSSEC has support for it, but my current linux install doesn't.

Inotify's been in the Linux kernel for over 4 years now...

Ok, so "current" was the wrong word. ;)

dayum

reminds me of the guy i worked with a couple of years ago who was responsible for keeping up the VOIP company's SIP server or something. he was running it on a fedora core 3 box when at least 7 was the current release.

My distro/version is at least supported. :p
 

aujames

Member
Jan 5, 2005
35
0
61
Thanks guys, inotify appears to be exactly what I need, only problem this box is AIX instead of Linux..
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Shoulda mentioned that in the first place. =)

I have no experience with AIX and don't know if it has something analogous to inotify.
 

xSauronx

Lifer
Jul 14, 2000
19,582
4
81
Originally posted by: n0cmonkey
Originally posted by: xSauronx
Originally posted by: n0cmonkey
Originally posted by: Nothinman
OSSEC has support for it, but my current linux install doesn't.

Inotify's been in the Linux kernel for over 4 years now...

Ok, so "current" was the wrong word. ;)

dayum

reminds me of the guy i worked with a couple of years ago who was responsible for keeping up the VOIP company's SIP server or something. he was running it on a fedora core 3 box when at least 7 was the current release.

My distro/version is at least supported. :p

:thumbsup: :D
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: aujames
Thanks guys, inotify appears to be exactly what I need, only problem this box is AIX instead of Linux..

Oops. I don't know AIX, but a quick shell/perl/python/whatever script could take care of that. Doesn't need to be cron'ed, just have it loop after a little nap.
 

aujames

Member
Jan 5, 2005
35
0
61
Originally posted by: n0cmonkey
Originally posted by: aujames
Thanks guys, inotify appears to be exactly what I need, only problem this box is AIX instead of Linux..

Oops. I don't know AIX, but a quick shell/perl/python/whatever script could take care of that. Doesn't need to be cron'ed, just have it loop after a little nap.

Good idea, I'll give that a try.

Thanks!
 

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
Originally posted by: xSauronx
Originally posted by: n0cmonkey
Originally posted by: Nothinman
OSSEC has support for it, but my current linux install doesn't.

Inotify's been in the Linux kernel for over 4 years now...

Ok, so "current" was the wrong word. ;)

dayum

reminds me of the guy i worked with a couple of years ago who was responsible for keeping up the VOIP company's SIP server or something. he was running it on a fedora core 3 box when at least 7 was the current release.

I just removed a Fedora Core 2 machine from production about 2 weeks ago. It ran for 3 years without a single hiccup, not even a single reboot before it died due to a power supply failure. I replaced the power supply and it ran for almost another 2 years (again, without a single reboot or a single second of downtime) before I replaced a couple weeks ago.

And the only reason I replaced it is because it was located at a remote office and a network redesign allowed me to pull that back into our main datacenter and put it in a virtual machine. Otherwise, why replace a machine that has 99.999% uptime?
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Brazen
Originally posted by: xSauronx
Originally posted by: n0cmonkey
Originally posted by: Nothinman
OSSEC has support for it, but my current linux install doesn't.

Inotify's been in the Linux kernel for over 4 years now...

Ok, so "current" was the wrong word. ;)

dayum

reminds me of the guy i worked with a couple of years ago who was responsible for keeping up the VOIP company's SIP server or something. he was running it on a fedora core 3 box when at least 7 was the current release.

I just removed a Fedora Core 2 machine from production about 2 weeks ago. It ran for 3 years without a single hiccup, not even a single reboot before it died due to a power supply failure. I replaced the power supply and it ran for almost another 2 years (again, without a single reboot or a single second of downtime) before I replaced a couple weeks ago.

And the only reason I replaced it is because it was located at a remote office and a network redesign allowed me to pull that back into our main datacenter and put it in a virtual machine. Otherwise, why replace a machine that has 99.999% uptime?

How did you handle patches?