execute a script on change to resolv.conf
Hi, I would like to execute a scrit every time the /etc/resolv.conf file is modified. Is there a way to do that? thanks, Osho
On 11/15/05, Osho GG
Hi,
I would like to execute a scrit every time the /etc/resolv.conf file is modified. Is there a way to do that?
I am not aware of an effective solution with a script (except copying
the file to another place and checking for modifications on a regular
basis), but with kernel 2.6 you can utilize /dev/inotify which has
been developed for this purpose. IBM provides some example code that
compiles out of the box and monitors any directory.
inotify is outlined in here:
http://www-128.ibm.com/developerworks/linux/library/l-inotify.html
and code can found right at the botton. You can filter the events
(e.g. IN_MODIFY) you are willing to receive.
\Steve
--
Steve Graegert
Thanks for the very useful info. I am using one of the SUSE supplied
kotd (kernel of the day) and I noticed that I have CONFIG_INOTIFY=y in
.config. However, there is no /dev/inotify. Also dmesg | grep inotify
does not show anything. How do I know what is the inotify minor
version? Do I still need to apply inotify patches if CONFIG_INOTIFY=y
for 2.6.14 kernel?
thanks,
Osh
On 11/15/05, Steve Graegert
On 11/15/05, Osho GG
wrote: Hi,
I would like to execute a scrit every time the /etc/resolv.conf file is modified. Is there a way to do that?
I am not aware of an effective solution with a script (except copying the file to another place and checking for modifications on a regular basis), but with kernel 2.6 you can utilize /dev/inotify which has been developed for this purpose. IBM provides some example code that compiles out of the box and monitors any directory.
inotify is outlined in here: http://www-128.ibm.com/developerworks/linux/library/l-inotify.html
and code can found right at the botton. You can filter the events (e.g. IN_MODIFY) you are willing to receive.
\Steve
--
Steve Graegert
Software Consultant {C/C++ && Java && .NET} Office: +49 9131 7123988 Mobile: +49 1520 9289212 -- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
-- Osho
On 11/15/05, Osho GG
Thanks for the very useful info. I am using one of the SUSE supplied kotd (kernel of the day) and I noticed that I have CONFIG_INOTIFY=y in .config. However, there is no /dev/inotify. Also dmesg | grep inotify does not show anything. How do I know what is the inotify minor version? Do I still need to apply inotify patches if CONFIG_INOTIFY=y for 2.6.14 kernel?
Make sure fstab contains the option user_xattr for the filesystem you
want to monitor. Minor 63 should be sufficient. When creating the
device manually calling 'mknod /dev/inotify c 10 63', do you get the
"no such device" error? Can you see /proc/sys/fs/inotify/?
[post trimmed]
\Steve
--
Steve Graegert
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Tuesday 2005-11-15 at 00:29 -0800, Osho GG wrote:
I would like to execute a scrit every time the /etc/resolv.conf file is modified. Is there a way to do that?
It is modified by /etc/ppp/ip-up, and perhaps a similar one for dhcp. - -- Cheers, Carlos Robinson -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) Comment: Made with pgp4pine 1.76 iD8DBQFDeeAltTMYHG2NR9URApE/AJ9Mp5oIOXbx3mDiIxitYZO9sONqpwCfbr/f lPp/ZZFJ1hMUDVFVZ3zrpEw= =rnJH -----END PGP SIGNATURE-----
participants (3)
-
Carlos E. R.
-
Osho GG
-
Steve Graegert