Find the answer to your Linux question:
Results 1 to 4 of 4
I'm writing a program (something like an antivirus) which scans files. it is running with cron every minute and finds files modified in past 1 minute (with find command) then ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2010
    Posts
    5

    modified files


    I'm writing a program (something like an antivirus) which scans files.
    it is running with cron every minute and finds files modified in past 1 minute (with find command) then starts its work on found files, it works nicely and does what I expect but the problem is that it is a bit heavy because find command is not so fast (and needs a lot of resources) and also it might take to a minute for a file to be scanned

    I would like to know if there is a way to run a command on every file whenever it is modified, I mean
    whenever a file is modified, a command runs on it, is it possible to do such a thing in Linux?

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,445
    inotify may work for you, or more specific incrond.
    I use it on production backend systems inotify - get your file system supervised

    If you are on a redhat based distro, then it is available from EPEL
    EPEL - FedoraProject
    Or you choose to build your own RPM, to not mix dependencies between centos/redhat and the epel repositories.
    Last edited by Irithori; 11-20-2010 at 11:13 AM.
    You must always face the curtain with a bow.

  3. #3
    Just Joined!
    Join Date
    Nov 2010
    Posts
    5
    Thanks a lot, that was exactly what I was looking for

  4. $spacer_open
    $spacer_close
  5. #4
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,445
    Have fun

    Alternatively, I just found iWatch
    iWatch

    It might be a little harder to package due to perl dependencies
    Linux::Inotify2, Event, Mail::Sendmail and XML::Simple.

    On the good side, you gain more features compared to the simple incrond.
    Most noteable the ability to
    - watch a directory recursively
    - exclude directories and files via regex
    - match files via regex
    Last edited by Irithori; 11-20-2010 at 02:04 PM.
    You must always face the curtain with a bow.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •