Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a crontab that includes many users updating it. The problem is that because of this, it is not easy to know who did what modification of a cronjob.

I was thinking to create a script to do a diff of the crontab with a previously saved version to at least be able to see what has been changed, but I thought that perhaps there is a standard solution for this. What is the best approach for managing my crontab?

share|improve this question
up vote 3 down vote accepted


I would put the contents of the crontab under subversion control and only grant access to this user through sudo. Specifically I would only allow people access to the a command via sudo that would take the head from subversion, and install it as the latest crontab for this particular user. This will provide you with the following:

  • An audit trail of who did what
  • The ability to roll back to a previous crontab file if a problem arises
  • Insulate the operators from having too much permission for this special account

It might seem overly complicated but there is nothing too complicated with what I described if you break it up into small chunks.


Another approach would be to use a tool/script such as MultiCron. This tool would allow you to manage the crontab data external to the crontab entry so that you could better control who/when has access to these changes.

Example Using Subversion

Assuming you'd setup a SVN repository you could create a sudo entry which would allow users to do something like this:

$ sudo deploy_app_cron.bash

The innards of this script could do among other things this:

svn cat file:///home/saml/svnrepo/app_cron_data.txt | crontab -u saml -

The contents of the file app_cron_data.txt:

$ svn cat file:///home/saml/svnrepo/app_cron_data.txt
*/5 * * * * /path/to/job -with args"

Example Usage Loop

So userA wants to update the crontab entry. They would do the following to start:

$ cd $HOME/somedir
$ svn co file:///home/saml/svnrepo/ mywksp
A    mywksp/app_cron_data.txt
$ cd mywksp

Now they do some edits to the crontab file, app_cron_data.txt, and commit them to the repo when they're done.

$ svn commit -m "some msg.." app_cron_data.txt

To deploy these changes they'd run this sudo command:

$ sudo deploy_app_cron.bash


share|improve this answer
s/subversion/a version control system/ — for this use case even RCS would do – Gilles Oct 7 '13 at 23:59
@slm:Use versioning. Ok. But I can not understand what you mean by take the head from subversion, and install it as the latest crontab for this particular user. How sudo is involved in this? – Jim Oct 8 '13 at 5:57
@Jim - see updates. – slm Oct 9 '13 at 13:05
@slm:great answer. Thank you and I am sorry for not accepting earlier – Jim Feb 15 '14 at 20:19
@slm:Thanks for pointing out.I will amend this asap.I am also very happy with this SE and the high quality of answers I get. – Jim Feb 15 '14 at 20:23

Well the right solution is to use cron properly and let each user have their own per-user crontab. Is there some omitted reason as to why you'd be setting up crontabs this way? It may even be more preferable to use per-user crontabs and some other workaround to whatever this "unified crontab" is intended to overcome... ?

share|improve this answer
There is only one user's tab shared and this can not change (this user has specific priviliges) – Jim Oct 7 '13 at 21:14
Then per user crontabs and SUDO would be an alternative? – iain Oct 7 '13 at 21:46
Another suggestion, if you're dead set on sharing a crontab - use a version control system (git, cvs, svn) to host the necessary file, and have the server check it out to the necessary location when its checked in. Then you have full versioning and rollback, which is what you're going to be after if you're looking to audit a completely collaborative work. The crontab/sudo option is better if each user has their own lines they are responsible for. – iain Oct 7 '13 at 21:48
have the server check it out to the necessary location when its checked in How do I do this?Could you elaborate please? – Jim Oct 8 '13 at 6:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.