68

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?

Falcon Momot
  • 24,975
  • 13
  • 61
  • 92
bflora
  • 819
  • 1
  • 6
  • 3
  • 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 `` to indicate that it's not the literal string "user" you need to give, – Vatine Sep 29 '10 at 09:35

2 Answers2

107

Try

crontab -e -u jake

You will need to be root for this to work.

Darryl Hein
  • 1,662
  • 2
  • 19
  • 21
MadHatter
  • 78,442
  • 20
  • 178
  • 229
  • 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 '10 at 10:23
  • @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 '20 at 18:51
0

you need sudo/root to edit any of crontab

Rajat
  • 3,329
  • 21
  • 29