0

I have a directory with several, or even hundreds of xml files in it. I want to execute a script when a new file is found. the only MAJOR problem is I can't use inotifywait or something like that. Due to limitation of install rights. (I do have the rights, but I'm not allowed due to agreements because it's maintained by our supplier). So I can use scripts, using the basic linux tools, but can't install new tools. One extra note, it has to be written for a quite old OS, opensuse 10.2.

Hope someone can help me point in the right direction.

regards,

1 Answer 1

0

Here is a short example of simple bash scripting using "find -newer" in a loop:

#!/bin/bash
while [ 1 ]; do
  newfiles=`find /tmp -newer /tmp/.my_marker 2>/dev/null`
  touch /tmp/.my_marker
  if [ -n "$newfiles" ]; then
    echo "found files $newfiles"
  fi
  sleep 5
done

In this example, the script finds files in /tmp which changed since last loop using the modification time of /tmp/.my_marker updated each time. Loop sleeps for 5 seconds before next check.

The action is just an echo of found files, you can put your own action instead.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .