From owner-freebsd-questions@FreeBSD.ORG Thu Jul 17 02:12:20 2008 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 6EA6D106566C for ; Thu, 17 Jul 2008 02:12:20 +0000 (UTC) (envelope-from jalmberg@identry.com) Received: from mx1.identry.com (on.identry.com [66.111.0.194]) by mx1.freebsd.org (Postfix) with ESMTP id DD1008FC15 for ; Thu, 17 Jul 2008 02:12:19 +0000 (UTC) (envelope-from jalmberg@identry.com) Received: (qmail 80798 invoked by uid 89); 17 Jul 2008 02:12:19 -0000 Received: from unknown (HELO ?192.168.1.110?) (jalmberg@75.127.142.66) by mx1.identry.com with ESMTPA; 17 Jul 2008 02:12:19 -0000 Mime-Version: 1.0 (Apple Message framework v752.3) In-Reply-To: References: <3BC71C1E-DD8B-4FD9-870A-A2D385E556C8@identry.com> <20080716113718.b165f10c.wmoran@potentialtech.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <98072606-5018-4DB1-82CA-259BA0665D69@identry.com> Content-Transfer-Encoding: 7bit X-Marketcircle-Dmi-Agent: <98072606-5018-4DB1-82CA-259BA0665D69@identry.com> From: John Almberg Date: Wed, 16 Jul 2008 22:12:16 -0400 To: freebsd-questions@freebsd.org X-Mailer: Apple Mail (2.752.3) Subject: Re: how to simulate a user's crontab? 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: Thu, 17 Jul 2008 02:12:20 -0000 On Jul 16, 2008, at 10:03 PM, John Almberg wrote: >> >> I'm guessing you're having problems with environment settings, >> although >> the vagaries of the question don't give me much to go on (something >> along the lines of, "when I try to do x in cron, I get the error y; >> but it works fine when the user runs it outside of cron" would be >> more >> informative.) >> > > Well, this got me thinking and I had to do some playing around to > figure out what was wrong... > > The difference was that I was testing the command by su-ing into > the user, rather than logging in as that user. What I didn't know > was su does not change your environment, only permissions (as far > as I can tell) > > So I was testing with my environment, but crontab was running under > the other user's environment. > > I always thought that su user and login user were equivalent. Now I > know better :-) Ah! Further digging led me to the - option for su... I am adding this note in case anyone else runs into this problem... Normal su does not change most of your environment... you retain the environment you had before typing 'su user'. However, typing 'su - user' simulates a full login. Amazing what you can find once you know what to look for! -- John