75

I have a user on my linux server who has sudo. I want to edit the crontab of another user. I'm new to this though and don't understand what the man pages are telling me yet.

Man crontab tells me I can use this format for the crontab command:

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

But what does that mean? I want to edit the crontab of a user named jake

so I tried

crontab jake -e
crontab [jake] -e
crontab [-u jake] -e

And I get the same error every time: "usage error: no arguments permitted after this option"

So what do I type in to edit jake's crontab?

1
  • 1
    The [ -u user ] means that you can optionally say -u user. I would've expected to see user either in italics (when typeset) or as <user> to indicate that it's not the literal string "user" you need to give,
    – Vatine
    Sep 29, 2010 at 9:35

2 Answers 2

114

Try

crontab -e -u jake

You will need to be root for this to work.

2
  • 14
    sudo crontab -e -u jake would work without being root, and gets logged. Could also su jake and then do crontab -e but sudo much better.
    – dunxd
    Sep 29, 2010 at 10:23
  • 2
    @dunxd su doesn't work with disabled users or users without login shell. Like www-data is not a user you can switch to on many systems, yet this user has cronjobs to do.
    – Daniel W.
    May 19, 2020 at 18:51
0

you need sudo/root to edit any of crontab

4
  • 4
    On many systems you can edit your own crontab without sudo/root.
    – Jenny D
    Nov 20, 2014 at 13:29
  • @JennyD AFAIK if you have not add user entry in following file it wont work. # vi /etc/security/access.conf
    – Rajat
    Nov 20, 2014 at 14:47
  • 1
    There are many varieties of unix, and many flavours of linux. Blocking crontab from regular users does not happen in all of them.
    – Jenny D
    Nov 20, 2014 at 19:38
  • 2
    How is this an answer? The OP already specified he has sudo.
    – simlev
    Jan 2, 2019 at 10:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .