Go to main content

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

Exit Print View

Updated: January 2019
 
 

Displaying and Verifying crontab Files

You can use the crontab –l command to display and verify contents of a crontab file.

Verifying That a crontab File Exists

To verify that a crontab file exists for a user, use the ls -l command in the /var/spool/cron/crontabs directory. The following sample output shows that crontab files exist for various users on the system.

$ ls -l /var/spool/cron/crontabs
drwxr-xr-x   2 root     sys           12 Nov 26 16:55 ./ 
drwxr-xr-x   4 root     sys            4 Apr 28  2012 ../ 
-rw-------   1 root     sys          190 Jun 28  2011 adm 
-rw-------   1 root     staff          0 Nov 13  2012 mary 
-rw-------   1 root     un           437 Oct  8  2012 johndoe 
-r--------   1 root     root         453 Apr 28  2012 lp 
-rw-------   1 root     sparccad      63 Jul 17 10:39 mary2 
-rw-------   1 root     sparccad     387 Oct 14 15:15 johndoe2 
-rw-------   1 root     other       2467 Nov 26 16:55 root 
-rw-------   1 root     sys          308 Jun 28  2011 sys 
-rw-------   1 root     siete        163 Nov 20 10:40 mary3
-r--------   1 root     sys          404 Jan 24  2013 uucp 

Displaying a crontab File

The crontab –l command displays the contents of a crontab file the same way that the cat command displays the contents of other types of files. You do not have to change the directory to /var/spool/cron/crontabs (where crontab files are located) to use this command.

By default, the crontab –l command displays your own crontab file. To display crontab files that belong to other users, you must assume the root role.

The crontab command can be used as follows:

# crontab -l [username]

where username specifies the name of the user's account for which you want to display a crontab file. Displaying another user's crontab file requires root privileges.


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.


Example 35  Displaying a crontab File

This example shows how to use the crontab -l command to display the contents of the default crontab file.

$ crontab -l
13 13 * * * chmod g+w /home1/documents/*.book > /dev/null 2>&1
Example 36  Displaying the Default root crontab file.

This example shows how to display the default root crontab file.

$ su
Password:

# crontab -l
#ident  "@(#)root       1.19    98/07/06 SMI"   /* SVr4.0 1.1.3.1       */
#
# The root crontab should be used to perform accounting data collection.
#
#
10 3 * * * /usr/sbin/logadm
15 3 * * 0 /usr/lib/fs/nfs/nfsfind
30 3 * * * [ -x /usr/lib/gss/gsscred_clean ] && /usr/lib/gss/gsscred_clean
#10 3 * * * /usr/lib/krb5/kprop_script ___slave_kdcs___
Example 37  Displaying the crontab File of Another User

This example shows how to display the crontab file that belongs to another user.

$ su
Password:
# crontab -l jones
13 13 * * * cp /home/jones/work_files /usr/backup/. > /dev/null 2>&1