Go to main content

Managing System Information, Processes, and Performance in Oracle® Solaris 11.4

Exit Print View

Updated: October 2019
 
 

Removing crontab Files

By default, crontab file protections are set up such 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, the crontab -r command removes your own crontab file.

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

How to Remove a crontab File

Before You Begin

Become an administrator to remove a crontab file that belongs to root or another user. Roles contain authorizations and privileged commands. For more information, see Using Your Assigned Administrative Rights in Securing Users and Processes in Oracle Solaris 11.4.

You do not need to assume the root role 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. To remove crontab files for another user, assume the root role.


    Caution

    Caution  -  If you accidentally type the crontab command with no option, press the interrupt character for your editor to quit without saving changes. If you instead save changes and exit the file, the existing crontab file will be overwritten with an empty file.


  2. Verify that the crontab file has been removed.
    # ls /var/spool/cron/crontabs
Example 37  Removing a crontab File

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

$ ls /var/spool/cron/crontabs
adm     jdoe     root    dsmith    sys     uucp
$ crontab -r
$ ls /var/spool/cron/crontabs
adm     jdoe	root    sys    uucp