From owner-freebsd-questions@FreeBSD.ORG Tue Oct 11 14:26:03 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 365BE1065673 for ; Tue, 11 Oct 2011 14:26:03 +0000 (UTC) (envelope-from ml@my.gd) Received: from mail-wy0-f182.google.com (mail-wy0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id C7F3B8FC19 for ; Tue, 11 Oct 2011 14:26:02 +0000 (UTC) Received: by wyj26 with SMTP id 26so11088240wyj.13 for ; Tue, 11 Oct 2011 07:26:01 -0700 (PDT) Received: by 10.227.59.212 with SMTP id m20mr7874828wbh.59.1318343161800; Tue, 11 Oct 2011 07:26:01 -0700 (PDT) Received: from dfleuriot-at-hi-media.com ([83.167.62.196]) by mx.google.com with ESMTPS id e7sm6270232wbh.12.2011.10.11.07.25.59 (version=SSLv3 cipher=OTHER); Tue, 11 Oct 2011 07:26:00 -0700 (PDT) Message-ID: <4E9451F6.7020800@my.gd> Date: Tue, 11 Oct 2011 16:25:58 +0200 From: Damien Fleuriot User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 To: freebsd-questions@freebsd.org References: <20111011155750.2f70109d.freebsd@edvax.de> In-Reply-To: <20111011155750.2f70109d.freebsd@edvax.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: User tasks in ~/.logout X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2011 14:26:03 -0000 On 10/11/11 3:57 PM, Polytropon wrote: > I have some users who I want to "schedule" a specific job > for which gets executed on their user account. For some > of them, it will be twice a day, for others just once a > month. It should happen at logout time. > > The intended mechanism to do so is ~/.logout, the C shell's > logout script. > > Example: The user quits his work (shell "exit" or ending > a custom program that is executed by the shell), > now the ~/.logout shoult be executed, e. g. copying his > current datasets to "immediate backup" (or other means of > processing). > > I assume I cannot use this approach when the user runs > his specific program _as_ the shell (per /etc/passwd), > but that's not a problem now, as it's easier to give > a regular shell and use ~/.login to "auto-exec" the > user-specific program). > > My question is: As users connect to the system per SSH, > how much time will the "at logout time" process have to > finish work, or does it work _any_ time after the user > has (1st) logged out and (2nd) terminated SSH connection > (e. g. disconnect from SSH CLI client or PuTTY)? > > Will such a ~/.logout job finish even if the user closes > his connection right after logout? > > And just in case a user does not properly log out (e. g. > closes PuTTY right from the open session, maybe from within > the program or shell he currently runs), will this cause > ~/.logout to be processed, or will it be a "stale connection"? > > I would suggest creating a dummy script that simply echoes the date to a file. Test your different scenarios, see if your file was written to correctly. If that works, insert a delay in your script, for example sleep 20.