How to write a daemon program to monitor symbolic links?

P

Peng Yu

As far as I know, linux doesn't support a system level way to figure
out all the symbolic links point to a give file. I could do a system
wide search to look for any symbolic link that point to the file that
I am interested in. But this will be too slow when there are many
files in the systems.

I'm thinking of writing a daemon program which will build a database
on all the symbolic links that point to any files. Later on, whenever
I change or remove any file or symbolic link, I'll will notify the
daemon process the changes. By keeping this daemon process running, I
can quickly figure out what symbolic links are pointing to any give
file.

But I have never make a daemon program like this in python. Could
somebody point me what packages I need in order to make a daemon
process like this? Thank you!
 
F

Falcolas

As far as I know, linux doesn't support a system level way to figure
out all the symbolic links point to a give file. I could do a system
wide search to look for any symbolic link that point to the file that
I am interested in. But this will be too slow when there are many
files in the systems.

I'm thinking of writing a daemon program which will build a database
on all the symbolic links that point to any files. Later on, whenever
I change or remove any file or symbolic link, I'll will notify the
daemon process the changes. By keeping this daemon process running, I
can quickly figure out what symbolic links are pointing to any give
file.

But I have never make a daemon program like this in python. Could
somebody point me what packages I need in order to make a daemon
process like this? Thank you!

I would recommend looking into some articles on creating well behaved
daemons and review python recipes for creating daemonic processes.
From there, it's mostly a matter of writing code which is fairly self
reliant. The ability to write to the system logs (Python module
syslog) helps quite a bit.

http://www.google.com/search?q=writing+daemons
http://code.activestate.com/recipes/278731/

I typically write a program which will run from the command line well,
then add a switch to make it a daemon. That way, you have direct
control over it while writing the daemon, but can then daemonize it
(using the activestate recipe) without making changes to the code.

Garrick
 
F

Falcolas

I would recommend looking into some articles on creating well behaved
daemons and review python recipes for creating daemonic processes.
From there, it's mostly a matter of writing code which is fairly self
reliant. The ability to write to the system logs (Python module
syslog) helps quite a bit.

http://www.google.com/search?q=writing+daemonshttp://code.activestate.com/recipes/278731/

I typically write a program which will run from the command line well,
then add a switch to make it a daemon. That way, you have direct
control over it while writing the daemon, but can then daemonize it
(using the activestate recipe) without making changes to the code.

Garrick

One other note - sorry for the double post - if you look at other
programs which maintain a DB of files, such as unix' slocate program,
update the DB as a daily cron job. You may want to also consider this
route.

Garrick
 
A

Aahz

I'm thinking of writing a daemon program which will build a database
on all the symbolic links that point to any files. Later on, whenever
I change or remove any file or symbolic link, I'll will notify the
daemon process the changes. By keeping this daemon process running, I
can quickly figure out what symbolic links are pointing to any give
file.

But I have never make a daemon program like this in python. Could
somebody point me what packages I need in order to make a daemon
process like this? Thank you!

inotify
 
L

Lawrence D'Oliveiro

Peng Yu said:
As far as I know, linux doesn't support a system level way to figure
out all the symbolic links point to a give file.

Do you know of a system that does?
I'm thinking of writing a daemon program which will build a database
on all the symbolic links that point to any files. Later on, whenever
I change or remove any file or symbolic link, I'll will notify the
daemon process the changes.

What if the change is made to a removable/hot-pluggable volume while it's
mounted on another system?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top