Shin938
Shin938

Reputation: 979

Monitor directory for file changes on Linux

I have a directory with files. An application is going to scan these files and then in some way mark each file as scanned. Then I want to get a notification that a file was scanned and delete it.

How can the application mark the file as scanned?

Regular attributes are not suited for me because for example the file could be read by someone but it doesn't mean it was scanned. How can I get a notification about scanned files?

Thank you.

Upvotes: 1

Views: 1291

Answers (3)

shem
shem

Reputation: 4712

I would recommend you not to go for a "file system" solution, it can be pretty complicated and buggy.

How about a that the scanned service will send a message to the deletion service after each file that was scanned?

Upvotes: 0

dda
dda

Reputation: 6213

The application that scans the files should keep a record of which files it has already scanned. Either a text file of a small database...

Upvotes: 0

tuergeist
tuergeist

Reputation: 9401

You can use inotify (manpage) to get notified about changes. You're getting notified only once. so there is no need to mark things as 'notified'.

An example is given here.

Upvotes: 2

Related Questions