Find the answer to your Linux question:
Results 1 to 4 of 4
Hi, I have a shell script which monitors a file at fixed intervals. This file is continuously being written, so my shell script gets only the freshly written information in ...
  1. #1
    Just Joined!
    Join Date
    Apr 2010
    Location
    Boston
    Posts
    1

    Cool multithreading in linux

    Hi,

    I have a shell script which monitors a file at fixed intervals. This file is continuously being written, so my shell script gets only the freshly written information in the file when it is executed the next time (i have put it in the cronjob).

    Now i want to extend this script to monitor any number of files concurrently. Any suggestions?

    Right now if i want to monitor say 3 files then i have 3 copies of the same script (gave them different names .sh) handling 3 individual files.

    Best,
    Life

  2. #2
    Linux Guru
    Join Date
    Nov 2007
    Posts
    1,695
    You don't explain fully what your goal is.

    To "check" 3 files when the script is run...specify them as parameters to the script and have the script handle them appropriately. Or alternatively, hard code them in the script itself.

    Bash Scripting

    If you want your script to check all files *in parallel* to reduce runtime, Google "parallel bash scripts." This will likely require heavy-rewriting of your script.

  3. #3
    Linux Engineer GNU-Fan's Avatar
    Join Date
    Mar 2008
    Posts
    935
    Heh, have a look at this:
    Home - inotify-tools - GitHub
    Debian GNU/Linux -- You know you want it.

  4. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    GNU-Fan is absolutely correct. Use the inotify tools to monitor changes to files and/or directories.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

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