Sponsored Content
Top Forums UNIX for Advanced & Expert Users Dynamically add paths to inotify Post 302931404 by anil510 on Tuesday 13th of January 2015 12:13:22 AM
Old 01-13-2015
Dynamically add paths to inotify

I have initiated an inotify process with --fromfile option and the file contain the paths to be monitored.

Code:
/usr/local/maldetect/inotify/inotifywait -d -r -o /usr/local/maldetect/inotify/inotify_log --fromfile /usr/local/maldetect/sess/inotify.paths.28364 --exclude (^/var/tmp/mysql.sock) --timefmt %d %b %H:%M:%S --format %w%f %e %T -m -e create,move,modify

The file /usr/local/maldetect/sess/inotify.paths.28364 contain entries such as below.
Code:
/home/user1/public_html
/home/user2/public_html
/home/user3/public_html

There are almost 800 entries like this. What I need is, when a new user is created, the path /home/user4/public_html, should add the path dynamically to the existing inotify process without needing to re-initate the inotify process. As the initialization of inotify process is a bit resource hogging. Or anyway by which, if we add the path /home/user4/public_html to the file /usr/local/maldetect/sess/inotify.paths.28364, the inotify process will dynamically read it.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

paths

Hi there! People, i'm a new unix user, and i'm having some problems... I'm updating some scripts (korn shell) in different servers. I use telnet to access these servers and emacs to write the scripts. One of them is an HP, and there´s no problem. But the other one is an AIX, and when i call... (1 Reply)
Discussion started by: caiohn
1 Replies

2. UNIX for Advanced & Expert Users

Spoofing paths.

There is a program that I am trying to run on a shell account. It depends on another program, which I have also copied to the shell account. Both are in my home directory, yet the first program has a different path hardcoded into it, which I cannot use because of permissions problems. How can I... (3 Replies)
Discussion started by: fahadsadah
3 Replies

3. Solaris

How to add new paths to $PATH

Hi all, I downloaded a tarball of coreutils .... extracted only to find out that i had to build it... But when i executed ./configure, this is what i got checking build system type... i386-pc-solaris2.11 checking host system type... i386-pc-solaris2.11 configure: autobuild project... GNU... (2 Replies)
Discussion started by: wrapster
2 Replies

4. SCO

inotify() in SCO UNIX

Hi I'm going to write a program in C language to watch activity on file system in SCO UNIX openserver 5.0.6. Apparently Linux provide an API called "inotify" , I'm wondering what's the SCO UNIX package for this ? (1 Reply)
Discussion started by: javad1_maroofi
1 Replies

5. What is on Your Mind?

Possible Career Paths

I've read through a couple of forum posts on Career issues but wanted to get some feedback that may be more personalized and whatnot. I am brand new to the world of UNIX and Linux and while I am finding the learning curve rather steep, I find it highly rewarding and am overall enjoying the... (2 Replies)
Discussion started by: huntreilly25
2 Replies

6. Shell Programming and Scripting

Add # dynamically to log file

Hello, I need help to add a # dynamically to a .txt file that contain files location I called the file listing.txt Dir1/Dir2/file_name Here is what I am trying to do. I am using a short shell ksh script on solaris. I am using a loop to read this log file line by... (3 Replies)
Discussion started by: Aswex
3 Replies

7. Shell Programming and Scripting

Hotfolder with inotify-tools, loop FOR not working

I can not understand why this little script with a loop processes only one file. At boot in /etc/rc.local i wrote: /usr/local/bin/./myscript & This is myscript: #!/bin/bash while inotifywait -e create /HOTFOLDER/ ; do for fullname in /HOTFOLDER/*.xlsx; do if !... (22 Replies)
Discussion started by: pasaico
22 Replies

8. Red Hat

Issues installing inotify-tools on RedHat Linux

I wish to install inotify-tools-3.20.1-2.4.x86_64.rpm on Linux and fire inotifywait command. Initially i was looking for "inotify-tools-3.xx.tar.gz" as instructed here http://jensd.be/248/linux/use-inotify-tools-on-centos-7-or-rhel-7-to-watch-files-and-directories-for-events I have... (9 Replies)
Discussion started by: mohtashims
9 Replies

9. UNIX for Advanced & Expert Users

Tip: inotify cron

Dear members, moderators and others. While working on <insert project>, a need has surfaced to watch a directory, and when a file comes, to do appropriate action. So, i started writing some shell code, aware of linux inotify-tools package with inotifywait. Also, i'm seeing a lot of similar... (1 Reply)
Discussion started by: Peasant
1 Replies
INOTIFY_ADD_WATCH(2)					     Linux Programmer's Manual					      INOTIFY_ADD_WATCH(2)

NAME
inotify_add_watch - add a watch to an initialized inotify instance SYNOPSIS
#include <sys/inotify.h> int inotify_add_watch(int fd, const char *pathname, uint32_t mask); DESCRIPTION
inotify_add_watch() adds a new watch, or modifies an existing watch, for the file whose location is specified in pathname; the caller must have read permission for this file. The fd argument is a file descriptor referring to the inotify instance whose watch list is to be modi- fied. The events to be monitored for pathname are specified in the mask bit-mask argument. See inotify(7) for a description of the bits that can be set in mask. A successful call to inotify_add_watch() returns the unique watch descriptor associated with pathname for this inotify instance. If path- name was not previously being watched by this inotify instance, then the watch descriptor is newly allocated. If pathname was already being watched, then the descriptor for the existing watch is returned. The watch descriptor is returned by later read(2)s from the inotify file descriptor. These reads fetch inotify_event structures (see ino- tify(7)) indicating file system events; the watch descriptor inside this structure identifies the object for which the event occurred. RETURN VALUE
On success, inotify_add_watch() returns a nonnegative watch descriptor. On error -1 is returned and errno is set appropriately. ERRORS
EACCES Read access to the given file is not permitted. EBADF The given file descriptor is not valid. EFAULT pathname points outside of the process's accessible address space. EINVAL The given event mask contains no valid events; or fd is not an inotify file descriptor. ENOMEM Insufficient kernel memory was available. ENOSPC The user limit on the total number of inotify watches was reached or the kernel failed to allocate a needed resource. VERSIONS
Inotify was merged into the 2.6.13 Linux kernel. CONFORMING TO
This system call is Linux-specific. SEE ALSO
inotify_init(2), inotify_rm_watch(2), inotify(7) COLOPHON
This page is part of release 3.25 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2006-02-07 INOTIFY_ADD_WATCH(2)
All times are GMT -4. The time now is 02:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy