System Administration Guide

Removing crontab Files

By default, crontab file protections are set up so that you cannot inadvertently delete a crontab file by using the rm command. Instead, use the crontab -r command to remove crontab files.

By default, crontab -r removes your own crontab file. You must be superuser to remove crontab files belonging to superuser or other users.

You do not have to change directories to /usr/spool/cron/crontabs (where crontab files are located) to use this command.

How to Remove a crontab File

  1. (Optional) To remove a crontab file belonging to root or another user, become superuser.

  2. Remove the crontab file.


    $ crontab -r [username]

    username

    Name of another user's account, and requires superuser privilegs to create or edit. 


    Caution - Caution -

    If you accidentally enter the crontab command with no option, press the interrupt character for your editor. This allows you to quit without saving changes. Exiting the file and saving changes at this point would overwrite an existing crontab file with an empty file.


  3. Verify the crontab file is removed.


    # ls /usr/spool/cron/crontabs
    

Example--Removing a crontab File

The following example shows how to use crontab -r to remove the default user's crontab file, as well as crontab files belonging to root and another user. ls verifies that the correct crontab files have been removed.


$ ls /usr/spool/cron/crontabs
adm     jones     lp     root    smith    sys
$ crontab -r
$ ls /usr/spool/cron/crontabs
adm     jones     lp     root    sys
$ su
Password:
# crontab -r
# ls /usr/spool/cron/crontabs
adm     jones     lp    sys
# crontab -r jones
# ls /usr/spool/cron/crontabs
adm     lp    sys