How to Remove a crontab File

Become the root user to remove a crontab file that belongs to root or another user. Roles contain authorizations and privileged commands.

You do not need to become root to remove your own crontab file.

  1. Remove the crontab file.
    # crontab -r [username]

    where username specifies the name of the user’s account for which you want to remove a crontab file. Removing crontab files for another user requires superuser privileges.

    Caution Caution – If you accidentally type the crontab command with no option, press the interrupt character for your editor. This character allows you to quit without saving changes. If you instead saved changes and exited the file, the existing crontab file would be overwritten with an empty file.

  2. Verify that the crontab file has been removed.
    # ls /var/spool/cron/crontabs

Example 14-5 Removing a crontab File

The following example shows how user smith uses the crontab -r command to remove his own crontab file.

$ ls /var/spool/cron/crontabs
adm     jones     root    smith    sys     uucp
$ crontab -r
$ ls /var/spool/cron/crontabs
adm     jones    root    sys    uucp

Tags: , , , , , , , , ,