[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Monitor files in a specific directory in C Programming Language in UNIX

Posted on 2009-05-07
7
Medium Priority
?
523 Views
Last Modified: 2013-12-26
Hi,

Is there a way we can monitor files in a specific directory in UNIX using C Programming Language?

What I want is, when a file (file1.txt) in a directory (example A directory) is moved to different directory (B directory) my C program will log it in a file. The program will add a line on a log file like:
"file1.txt is moved to B directory" ...

Is this possible in C? How? Or do you have any other recommendations?

Thanks a lot.

-jan
0
Comment
Question by:janjerell
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 40

Accepted Solution

by:
evilrix earned 2000 total points
ID: 24333646
Take a look at the inotify API

http://ibm5.ma.utexas.edu/cgi-bin/man-cgi?inotify+7

"The inotify API provides a mechanism for monitoring file system events.
Inotify can be used to monitor individual files, or to monitor directo-
ries.   When  a  directory is monitored, inotify will return events for
the directory itself, and for files inside the directory."

NB. The inotify API replaces the older dnotify.
0
 
LVL 3

Author Comment

by:janjerell
ID: 24334150
Thanks so much evilrix... I'll get back to you soon as I figured this out...
0
 
LVL 3

Author Comment

by:janjerell
ID: 24362431
Thanks evilrix.. I have it working right now... SOrry for the Grade.. It should be A.. I don't know how to change.. anyway, thanks again...
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 40

Expert Comment

by:evilrix
ID: 24362449
>> Thanks evilrix..
Most welcome.

>> SOrry for the Grade.. It should be A.
If you'd like to change the grade you can "Request Attention" by clicking the link at the top right of the page and posting a request in Community Support.
0
 
LVL 40

Expert Comment

by:evilrix
ID: 24371947
Many thanks indeed.
0
 
LVL 3

Author Comment

by:janjerell
ID: 24372036
thanks mod
0

Featured Post

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question