[Top][All Lists]

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

Re: Modifying Cron

From: wbmccarty
Subject: Re: Modifying Cron
Date: 17 Dec 2004 08:48:43 -0800
User-agent: G2/0.2

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.


reply via email to

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