Project

General

Profile

Feature #13066

Want crontab -u

Added by Andy Fiddaman 7 months ago. Updated 6 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
cmd - userland programs
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Bite-size
Tags:
Gerrit CR:

Description

It would be useful if the crontab command supported a -u username option to specify the username for the operation.

Without this, there is currently no easy way for root to replace a user's crontab, resulting in various tricks being employed such as:

                # Unfortunately, illumos cron does not allow for root to
                # easily replace a user's crontab, so we copy the file directly
                # into place and then edit the user's cron file with the
                # 'touch' editor a second later to cause cron to re-read.
                cp $file /var/spool/cron/crontabs/$user
                sleep 1
                env -i EDITOR=touch crontab -e $user

The -u option is also something that is common on other operating systems so adding it as a general flag will help with software portability and allow for removing workaround in various build systems (pkgsrc etc.) in the longer term.

Proposed new synopsis. Note that the three shipped copies of crontab will be updated with this change:

  • /usr/bin/crontab
  • /usr/xpg4/bin/crontab
  • /usr/xpg6/bin/crontab
SYNOPSIS
       /usr/bin/crontab [-u username] [filename]

       /usr/bin/crontab { -e | -l | -r } [username]

       /usr/bin/crontab -u username { -e | -l | -r }

       /usr/xpg4/bin/crontab [filename]

       /usr/xpg4/bin/crontab { -e | -l | -r } [username]

       /usr/xpg4/bin/crontab -u username { -e | -l | -r }

       /usr/xpg6/bin/crontab [filename]

       /usr/xpg6/bin/crontab { -e | -l | -r } [username]

       /usr/xpg6/bin/crontab -u username { -e | -l | -r }
#1

Updated by Electric Monk 7 months ago

  • Gerrit CR set to 861
#2

Updated by Andy Fiddaman 7 months ago

Webrev also at http://cr.illumos.org/~webrev/citrus/ig_13066_crontab-u/
for an easier way to view the man page changes.

#3

Updated by Andy Fiddaman 6 months ago

I tested this by building an updated crontab binary and then trying combinations of options to show that previous options continue to be accepted and perform the same function as previously, and that the new options work as expected in all combinations.

#4

Updated by Andy Fiddaman 6 months ago

  • Description updated (diff)
#5

Updated by Andy Fiddaman 6 months ago

  • Description updated (diff)
#6

Updated by Electric Monk 6 months ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

git commit 6863ede29751efd2be66ec1b48c3c0ee705d7d61

commit  6863ede29751efd2be66ec1b48c3c0ee705d7d61
Author: Andy Fiddaman <omnios@citrus-it.co.uk>
Date:   2020-08-25T15:11:53.000Z

    13066 Want crontab -u
    Reviewed by: Peter Tribble <peter.tribble@gmail.com>
    Reviewed by: Dominik Hassler <hadfl@omniosce.org>
    Approved by: Robert Mustacchi <rm@fingolfin.org>

Also available in: Atom PDF