[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Modifying Cron

From: Joe Moore
Subject: Re: Modifying Cron
Date: Fri, 17 Dec 2004 13:53:23 -0500
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040616

address@hidden wrote:

Ah, I see! Thanks for your patience.

Yes, that's a crucial difference between /etc/crontab and user cron
files.  The former can be safely edited in place, whereas the latter
should be installed using the crontab command. I haven't used Solaris
since it was just beginning to displace SunOS <g>. But, under Linux,
the crontab command supports listing and installing user cron files,
and includes an option allowing root to manipulate user's cron files:

crontab [ -u user ] file
crontab [ -u user ] { -l | -r | -e }

So, assuming that Solaris includes similar functionality, I think you'd
do something like the following:

1. Obtain current cron file:
crontab -u joe -l > /tmp/cronwork

2. Edit /tmp/cronwork using cfengine editfiles

3. Install potentially updated cron file:
crontab -u joe /tmp/cronwork

From the standpoint of security, it'd be best if the name of the work
file, /tmp/cronwork in my example, were generated dynamically so as not
to be predictable. That's a relatively simple elaboration of the basic
plan, using the mktemp command or a similar facility.

What do you think?

As I recall, the issue of installing, rather than directly editing,
user cron files has to do with cron knowing when a file has been
updated. But, that probably varies from one implementation of cron to
another. If my notion IS right, you could probably edit a cron file in
place and then run:

crontab -u joe -l > /tmp/cronwork
crontab -u joe /tmp/cronwork

This should alert cron to the change. Mind you, I'm speculating and
haven't actually tried this.

I've used:

actionsequence = ( shellcommands.getcron editfiles.editcron shellcommands.putcron )

   getcrontab:: "/usr/bin/crontab -l > $(workdir)/tmp/crontab.root

      { $(workdir)/tmp/crontab.root
Similar stuff that was editing /etc/crontab in the previous messages
         DefineClasses "reload_root_crontab"

      "/usr/bin/crontab $(workdir)/tmp/crontab.root"


reply via email to

[Prev in Thread] Current Thread [Next in Thread]