2

We are trying to write a script to move away files as soon as they drop in a folder. One way of achieving this is running rsync in a script on cron scheduler.

The problem with this approach is the system overhead. We cannot run it every second and if we run it after an interval of time then we leave the files vulnerable (accessible to senders) for that time gap. Reqirement is that the files should vanish as soon as they arrive.

I checked stackoverflow and found the incron command. But this is only available on Linux and not on Solaris.

1
  • With Solaris 10, you might try Gamin which has a Solaris port here.

  • With Solaris 11 and newer, there is the native and more efficient FEN (File Event Notification).

If for some reason, the polling nature of Gamin doesn't suit your needs and you want to stay on Solaris 10, there are at least a couple of alternative ways that might be explored:

  • enabling BSM audit and track the fc event (file create).
  • using Dtrace to react when a file is created on the directory to monitor.

In the latter case, you might even move the target files away from the directory in the dtrace script itself.

0

I know that you explicitly state Solaris 10 but if you were on Solaris 11 you could use use the watchdir command based on Solaris File Event Notification. Thereby you achieve close to 0% system overhead as opposed to any other solution which is inherently based on some kind of polling. This command is a blocking command that will wait forever (or using an argument with a timeout) for a file event to happen on a folder. Most typically it will be used for waiting for a new file to arrive.

If you really insist on Solaris 10 then I do not know of any method that would not be somehow based on polling.

It may also be worth noting that Java as of v7 has a build-in mechanism for watching the file system. The beauty of that solution is that it automatically takes advantage of the most efficient method for the platform in question. In other words your application will work today on Solaris 10 (presumably by Java using some kind of polling mechanism underneath) and then when you move to Solaris 11 that same application will then seamlessly take advantage of the Solaris File Events Notification mechanism underneath.

  • There are undoubtedly ways to do it without polling under Solaris 10. See my updated answer. – jlliagre Nov 3 '13 at 22:33
  • @jlliagre. Sweet. I agree, especially I would find the DTrace approach promising .. if you are still on Solaris 10. Good points. – unixhacker2010 Nov 16 '13 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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