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 that belong 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 that belongs to root or another user.
Remove the crontab file.
$ crontab -r [username] |
Where username specifies the name of the user's account for which you want to create or edit a crontab file. To create or edit crontab files requires superuser privileges.
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 is overwritten with an empty file.
Verify that 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 |