From owner-freebsd-questions@FreeBSD.ORG Wed Feb 16 13:55:20 2005 Return-Path: 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 61F5016A4CF for ; Wed, 16 Feb 2005 13:55:20 +0000 (GMT) Received: from mail24.sea5.speakeasy.net (mail24.sea5.speakeasy.net [69.17.117.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2BDA243D5E for ; Wed, 16 Feb 2005 13:55:20 +0000 (GMT) (envelope-from freebsd-questions-local@be-well.ilk.org) Received: (qmail 16861 invoked from network); 16 Feb 2005 13:55:19 -0000 Received: from dsl092-078-145.bos1.dsl.speakeasy.net (HELO be-well.ilk.org) ([66.92.78.145]) (envelope-sender ) by mail24.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 16 Feb 2005 13:55:19 -0000 Received: by be-well.ilk.org (Postfix, from userid 1147) id 1A05D7E; Wed, 16 Feb 2005 08:55:19 -0500 (EST) Sender: lowell@be-well.ilk.org To: Peter Risdon References: <1108546855.23699.320.camel@lorna.circlesquared.com> From: Lowell Gilbert Date: 16 Feb 2005 08:55:18 -0500 In-Reply-To: <1108546855.23699.320.camel@lorna.circlesquared.com> Message-ID: <447jl8boe1.fsf@be-well.ilk.org> Lines: 24 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii cc: "freebsd-questions@freebsd.org" Subject: Re: scripting crontab entries X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Feb 2005 13:55:20 -0000 Peter Risdon writes: > I want to be able to update a user's crontab from a script. tabs > in /var/cron/tabs carry a warning that the file should not be edited > directly, so presumably something like > > #echo "5 * * * * /some/script.sh" >> /var/cron/tabs/$USER > > is the wrong approach. Is the right approach: > > #cat ~/.mycrontab > 5 * * * * /some/script.sh > > #crontab ~/.mycrontab > > The right way to go? I notice this approach blows away existing crontab > entries, and was hoping to be able to append new ones instead, but then > by treating ~/.mycrontab as the master file, I can manage this OK. How about: crontab -u $USER -l > crontab.file.$USER echo "5 * * * * /some/script.sh" >> crontab.file.$USER crontab -u $USER crontab.file.$USER