From owner-freebsd-questions Sun Oct 6 15:28:49 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A6EC237B401 for ; Sun, 6 Oct 2002 15:28:48 -0700 (PDT) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2E3B343E86 for ; Sun, 6 Oct 2002 15:28:48 -0700 (PDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.6/8.12.5) id g96MSlc0028144; Sun, 6 Oct 2002 17:28:47 -0500 (CDT) (envelope-from dan) Date: Sun, 6 Oct 2002 17:28:47 -0500 From: Dan Nelson To: Lord Raiden Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Event Trigger Message-ID: <20021006222847.GA19470@dan.emsphone.com> References: <4.2.0.58.20021006013105.009687c0@pop.voyager.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4.2.0.58.20021006013105.009687c0@pop.voyager.net> X-OS: FreeBSD 5.0-CURRENT X-message-flag: Outlook Error User-Agent: Mutt/1.5.1i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In the last episode (Oct 06), Lord Raiden said: > Hi. I'm looking for a simple way to implement a trap and > trigger so to speak. I'm wanting to setup the system so that the > moment it detects a certain event in the system, it immediately > executes another script or program to do something else, but not > before, not after. I thought about Cron, but the thing is, I don't > know when these events will happen so since they're so random, I need > something to identify them then immediately run another script or > program at that exact moment. Any suggestions? It depends on what the event is. With kqueue, you can be notified when a file is changed or a process exits, and you can use those two events to detect just about anything. For example, if you're talking FTP uploads, you can ask to be notified whenever /var/log/xferlog (or whatever file your ftpd uses to log transfers) changes, then process any files that were added since the last time your scanner looked at the logfile. -- Dan Nelson dnelson@allantgroup.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message