|Skip Navigation Links|
|Exit Print View|
|System Administration Guide: Advanced Administration Oracle Solaris 11 Express 11/10|
You can control access to the crontab command by using two files in the /etc/cron.d directory: cron.deny and cron.allow. These files permit only specified users to perform crontab command tasks such as creating, editing, displaying, or removing their own crontab files.
The cron.deny and cron.allow files consist of a list of user names, one user name per line.
These access control files work together as follows:
If cron.allow does not exist, all users can submit crontab files, except for users who are listed in cron.deny.
If neither cron.allow nor cron.deny exists, superuser privileges are required to run the crontab command.
Superuser privileges are required to edit or create the cron.deny and cron.allow files.
$ cat /etc/cron.d/cron.deny daemon bin smtp nuucp listen nobody noaccess
None of the user names in the default cron.deny file can access the crontab command. You can edit this file to add other user names that will be denied access to the crontab command.
No default cron.allow file is supplied. So, after Oracle Solaris software installation, all users (except users who are listed in the default cron.deny file) can access the crontab command. If you create a cron.allow file, only these users can access the crontab command.
$ su - Password: #
Note - This method works whether root is a user or a role.
daemon bin smtp nuucp listen nobody noaccess username1 username2 username3 . . .
# cat /etc/cron.d/cron.deny daemon bin nuucp listen nobody noaccess
If you do not add root to the file, superuser access to crontab commands will be denied.
Include users that will be allowed to use the crontab command.
root username1 username2 username3 . . .
Example 3-6 Limiting crontab Command Access to Specified Users
The following example shows a cron.deny file that prevents user names jones, temp, and visitor from accessing the crontab command.
$ cat /etc/cron.d/cron.deny daemon bin smtp nuucp listen nobody noaccess jones temp visitor
$ cat /etc/cron.d/cron.allow root jones lp smith
To verify if a specific user can access the crontab command, use the crontab -l command while you are logged into the user account.
$ crontab -l
If the user can access the crontab command, and already has created a crontab file, the file is displayed. Otherwise, if the user can access the crontab command but no crontab file exists, a message similar to the following message is displayed:
crontab: can't open your crontab file
Either this user either is listed in the cron.allow file (if the file exists), or the user is not listed in the cron.deny file.
If the user cannot access the crontab command, the following message is displayed whether or not a previous crontab file exists:
crontab: you are not authorized to use cron. Sorry.
This message means that either the user is not listed in the cron.allow file (if the file exists), or the user is listed in the cron.deny file.