Skip site navigation (1)Skip section navigation (2)
Date:      16 Feb 2005 08:55:18 -0500
From:      Lowell Gilbert <freebsd-questions-local@be-well.ilk.org>
To:        Peter Risdon <peter@circlesquared.com>
Cc:        "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject:   Re: scripting crontab entries
Message-ID:  <447jl8boe1.fsf@be-well.ilk.org>
In-Reply-To: <1108546855.23699.320.camel@lorna.circlesquared.com>
References:  <1108546855.23699.320.camel@lorna.circlesquared.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Peter Risdon <peter@circlesquared.com> 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?447jl8boe1.fsf>