Shell script running as a daemon?
Zarnick Maelstorm
p.zarnick
Wed Jul 18 20:11:14 PDT 2007
On Wed, 18 Jul 2007 21:59:36 -0400, Kurt Wall wrote:
> On Jul 18, 2007, at 8:51 PM, Mateus Interciso wrote:
>
>> Hello, I'm planing on making a (hopefully) simple shell script that act
>> as a daemon. This particular shell script should keep watching a
>> folder,
>> and wenever a new txt file(all files that arrive on that folder are
>> txt)
>> arrives, it should grep trough it, and take some actions. My question
>> is if it's possible to make this kind of daemon?
>
> Sure. You're probably reinventing the wheel, but such a shell script is
> trivial to write:
>
> --- cut here ---
> #!/bin/bash
>
> # Create/update a sentinel file
> touch junk
>
> # Monitor the directory
> while [ true ]; do
> # find files newer than the sentinel file for f in `find .
> -newer junk`; do
> echo $f found
> done
> # update the timestamp on the "sentinel" file touch junk
> # sleep for 60 seconds
> sleep 60
> done
>
> --- cut here ---
>
> YMMV. If it breaks, you get to keep both pieces.
>
> KUrt
Thank Kurt, this for sure helps me, but why did you sayd I'm reinventing
the wheel?
I need to create a script that sits right after the mail-server, checks
the messages for a string, and then trigger an action against that
string. I touth it would be best to create a daemon that watchs the
Maildir folder I want to watch.
If there's any other way, please enlight me.
And once again, thanks a lot.
Mateus
More information about the Linux-users
mailing list