[Techtalk] Any difference in crontab listing

MMP - Barb Fox mmp_fox at bellsouth.net
Wed Jul 13 01:47:33 EST 2005

> > I want to set up a cron job (shell script). I know
> > there are two ways to do this. I can directly edit my
> > crontab list, or I can create, save, and load a text
> > file with my crontab entries. Is there any difference
> > in these two methods? Is one way better than the
> > other?
> >
>Not much difference. I prefer editing /etc/crontab for simple things. The
>advantage of using the crontab command is individual users can set up their
>own. /etc/crontab is editable only by the root user.

Another advantage of using the crontab -e command is that it does basic
syntax checking and will NOT save a crontab if it has an illegal number
of fields or values. Also, the permissions are always created perfectly
so you don't have to worry about chmod and chown commands.

If you don't like the idea of editing your "actual" crontab, here's what 
I'd suggest:
$ crontab -l > mycrontab.backup   #create a backup
$ crontab -l > mynewcrontab         # get a template to get started if you 
don't have one already
$ vi mynewcrontab
$ crontab mynewcrontab  #this installs mynewcrontab into system location

This way crontab is taking care of permissions, syntax checking, etc.
but you aren't actually "editing" the live crontab (and you have a
backup of the original in case you mess it up).

Barb Fox

This way you are not actually "editing" the live crontab 

More information about the Techtalk mailing list