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 /var/spool/cron/crontabs (where crontab files are located) to use this command.
(Optional) Become superuser to remove a crontab file belonging to root or another user.
Remove the crontab file.
$ crontab -r [username] |
username |
Name of another user's account, and requires superuser privileges to create or edit. |
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.
Verify the crontab file is removed.
# ls /var/spool/cron/crontabs |
The following example shows how user smith uses the crontab -r command to remove his crontab file.
$ ls /var/spool/cron/crontabs adm jones lp root smith sys uucp $ crontab -r $ ls /var/spool/cron/crontabs adm jones lp root sys uucp |