I have a directory that gets written to when other machines send files via FTP. I want to put something in place that notices when files arrive and if their file name contains a particular substring (like "jpg"), move the file to some other directory (only after the file has finished arriving, not before)

I want to put this in place on many different kinds of Linux boxes. One such box has Linux kernel 2.4.22. It is possible there are older ones. I'm still checking.

On the older machines, I see this: inotifywait: command not found.

I've also seen this: The inotify API is available in Linux 2.6.13 and later

And this: bash: watch: command not found

Ideas in POSIX sh or bash or C could work. Perl and Python are probably not available everywhere I want to run this. I don't have permission to install packages.

  • Why is inotifywait not available? Oct 8, 2015 at 19:32
  • man watch should give you what you need.
    – Jenny D
    Oct 8, 2015 at 19:35
  • The kernel is too old. No inotifywait and no watch Oct 9, 2015 at 20:15

1 Answer 1


I wrote this Perl program a long time ago that could get you started if you understand it. It uses uses the inotify feature in the kernel.


You'll have to change the code from synchronization to doing whatever you need, but it's mostly all there.

I know you have a problem with Perl, but I wanted to give this to you just in case.

If it helps, here's a demo on how to do it with C


  • Yeah, that C demo looks pretty easy to modify Oct 8, 2015 at 23:07
  • Ah. One of the older machines I have to run this on has Linux 2.4.22 and "the inotify API is available in Linux 2.6.13 and later" Oct 9, 2015 at 19:55
  • 1
    I think you'll need to create a script or something to constantly look for changes then. Oct 12, 2015 at 14:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.