Shell script running as a daemon?

Kurt Wall kwall
Thu Jul 19 18:21:26 PDT 2007


On Jul 19, 2007, at 7:30 AM, Mateus Interciso wrote:

> 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:

[script snipped]
>
> Kurt, thanks a lot, this will for sure help.
> But why do you say that I'm reinventing the whell?

I'm not criticizing, just suggesting that someone else
has probably already solved this problem and a quick
search on Freshmeat or SourceForge will show you what
other people have done.

> What I want is to create a daemon that keeps looking at a Maildir/cur
> folder, grep all new messages, and acording to the grep, it does some
> kind of action. I tought that a daemon was the best thing to  
> actually do,
> but if there's other way, a bether one, please enlight me.

There's more than one way to do it. A daemon is absolutely
a valid approach. A cron job is another way. What you are
describing is a "biff" (a mail notifier) that runs an external
process (your grep and "some kind of action") when it detects
new mail.

Again, I'm not criticizing your idea, just suggesting that it
has already been solved. There's nothing wrong with solving
it again, either. Who knows, maybe you'll solve it in a newer,
better, smarter way.

Best regards,

Kurt




More information about the Linux-users mailing list