System Administration Commands smcron(1M)
NAME
smcron - manage jobs in the crontab database
SYNOPSIS
/usr/sadm/bin/smcron subcommand [ auth_args] --
[subcommand_args]
DESCRIPTION
The smcron command manages jobs in the crontab(1) database.
subcommandssmcron subcommands are:
add Adds a job to the crontab(1) database. To add a job, the administrator must have the solaris.jobs.user authorization. To add a job to another user's crontab file, the administrator must have the solaris.jobs.admin authorization. delete Deletes a job from the crontab(1) database. To delete a job, the administrator must have the solaris.jobs.user authorization. To delete a jobfrom another user's crontab file, the administra-
tor must have the solaris.jobs.admin authoriza-
tion. list Lists one or more jobs in the crontab(1) database. To list all jobs, the administrator must have the solaris.jobs.user authorization. To list a job in another user's crontab file, the administrator must have the solaris.jobs.admin authorization. No authorization is needed to list a user's own jobs. modify Modifies a job in the crontab(1) database. To modify a job, the administrator must have the solaris.jobs.user authorization. To modify a job in another user's crontab file, the administrator must have the solaris.jobs.admin authorization. OPTIONSThe smcron authentication arguments, auth_args, are derived
from the smc(1M) arg set and are the same regardless ofwhich subcommand you use. The smcron command requires the
Solaris Management Console to be initialized for the command to succeed (see smc(1M)). After rebooting the SolarisManagement Console server, the first Solaris Management Con-
sole connection might time out, so you might need to retrySunOS 5.11 Last change: 24 Mar 2003 1
System Administration Commands smcron(1M)
the command.The subcommand-specific options, subcommand_args, must come
after the auth_args and must be separated from them by the
-- option.
auth_args
The valid auth_args are -D, -H, -l, -p, -r, and -u; they are
all optional. If no auth_args are specified, certain
defaults will be assumed and the user may be prompted foradditional information, such as a password for authentica-
tion purposes. These letter options can also be specified by their equivalent option words preceded by a double dash. Forexample, you can use either -D or --domain with the domain
argument.-D | --domain 13;domain
Specifies the default domain that you want to manage.smcron accepts only file for this option. file is also
the default value. The file default domain means that changes are local tothe server. Toolboxes can change the domain on a tool-
by-tool basis; this option specifies the domain for all
other tools.-H | --hostname 13;host_name:port
Specifies the host_name and port to which you want to
connect. If you do not specify a port, the system con-
nects to the default port, 898. If you do not specifyhost_name:port, the Solaris Management Console connects
to the local host on port 898. You may still have to choose a toolbox to load into the console. To overridethis behavior, use the smc(1M) -B option, or set your
console preferences to load a "home toolbox" by default.-l | --rolepassword 13;role_password
Specifies the password for the role_name. If you specify
a role_name but do not specify a role_password, the sys-
tem prompts you to supply a role_password. Passwords
specified on the command line can be seen by any user on the system, hence this option is considered insecure.-p | --password 13;password
SunOS 5.11 Last change: 24 Mar 2003 2
System Administration Commands smcron(1M)
Specifies the password for the user_name. If you do not
specify a password, the system prompts you for one. Passwords specified on the command line can be seen by any user on the system, hence this option is considered insecure.-r | --rolename 13;role_name
Specifies a role name for authentication. If you do not specify this option, no role is assumed.-u | --username 13;user_name
Specifies the user name for authentication. If you do not specify this option, the user identity running the console process is assumed.--
This option is required and must always follow the preceding options. If you do not enter the precedingoptions, you must still enter the -- option.
subcommand_args
For the time-related subcommands described below, -m, -M,
-t, and -w, you can enter multiple arguments, separated only
by commas. smcron will construct crontab entries appropriate
for your arguments. See EXAMPLES.
Note: Descriptions and other arg options that contain white spaces must be enclosed in double quotes. o For subcommand add:-c command Specifies the command that you
want to run.-h (Optional) Displays the
command's usage statement.-m day_of_month (Optional) Specifies the day of
the month you want to run thejob. Valid values are 1-31. If
you specify both -t and -m
SunOS 5.11 Last change: 24 Mar 2003 3
System Administration Commands smcron(1M)
options, the job executes oneday per month at the time speci-
fied by -t.
-M month (Optional) Specifies the month
that you want to run the job.Valid values are 1-12. If you
specify both -t and -M options,
the job executes during the specified month at the timespecified by -t.
-n name Specifies the unique name of the
job.-o owner (Optional) Specifies the user
name that is the owner of the job. If you do not specify this option, the user name specifiedby the -U option is assumed.
-t time_of_day Specifies the time (in hh:mm)
that you want to execute thecommand. If no other time-
related options are specified(-m, -M, or -w), the job exe-
cutes every day at the timespecified by -t. If you specify
both -t and -w options, the job
executes one day per week at thetime specified by -t. If you
specify both -t and -m options,
the job executes one day per month at the time specified by-t. If you specify both -t and
-M options, the job executes
each day during the specified month at the time specified by-t.
-w day_of_week (Optional) Specifies the day of
the week you want to execute the command. Valid values are as follows: o 0=SundaySunOS 5.11 Last change: 24 Mar 2003 4
System Administration Commands smcron(1M)
o 1=Monday o 2=Tuesday o 3=Wednesday o 4=Thursday o 5=Friday o 6=SaturdayIf you specify both -t and -w
options, the job executes oneday per week at the time speci-
fied by -t.
o For subcommand delete:-h (Optional) Displays the command's usage
statement.-n name Specifies the unique name of the job.
-o owner (Optional) Specifies the user name that
is the owner of the job. If you do not specify this option, the user namespecified by the -U option is assumed.
o For subcommand list:-f n|s|v (Optional) Specifies the format of the
output. See EXAMPLES for examples of
each output type.o n - Displays the data in
native format, as it appears in the crontab(1) database.o s - Default format. Displays
the data in summary format.o v - Displays the data in ver-
bose format.SunOS 5.11 Last change: 24 Mar 2003 5
System Administration Commands smcron(1M)
-h (Optional) Displays the command's usage
statement.-o owner (Optional) Lists all jobs for the
specified owner (user name). If you do not specify this option, all jobs in the crontab(1) database are listed. o For subcommand modify:-c command (Optional) Specifies the command
that you want to run.-h (Optional) Displays the
command's usage statement.-m day_of_month (Optional) Specifies the day of
the month you want to run thejob. Valid values are 1-31. If
you specify both -t and -m
options, the job executes oneday per month at the time speci-
fied by -t.
-M month (Optional) Specifies the month
that you want to run the job.Valid values are 1-12. If you
specify both -t and -M options,
the job executes during the specified month at the timespecified by -t.
-n name Specifies the current unique
name of the job.-N new_name (Optional) Specifies the new
unique name of the job.-o owner (Optional) Specifies the user
name that is the owner of the job. If you do not specify this option, the user name specifiedSunOS 5.11 Last change: 24 Mar 2003 6
System Administration Commands smcron(1M)
by the -U option is assumed.
-O new_owner (Optional) Specifies the new
owner of the job.-t time_of_day (Optional) Specifies the time
(in hh:mm) that you want to exe-
cute the command. If no othertime-related options are speci-
fied (-m, -M, or -w), then the
job executes every day at thetime specified by -t. If you
specify both -t and -w options,
the job executes one day per week at the time specified by-t. If you specify both -t and
-m options, the job executes one
day per month at the time speci-
fied by -t. If you specify both
-t and -M, then the job executes
each day during the specified month at the time specified by-t.
-w day_of_week (Optional) Specifies the day of
the week you want to execute the command. Valid values are as follows: o 0=Sunday o 1=Monday o 2=Tuesday o 3=Wednesday o 4=Thursday o 5=Friday o 6=SaturdayIf you specify both -t and -w
options, the job executes oneday per week at the time speci-
fied by -t.
SunOS 5.11 Last change: 24 Mar 2003 7
System Administration Commands smcron(1M)
EXAMPLES
Example 1 Adding a Job The following adds a new job, owned by root, that removes the old log files from /tmp daily at 1:30 AM../smcron add -H myhost -u root -p mypassword -- -n "Remove old logs" \
-t 1:30 -c "rm /tmp/*.log" -o root
Example 2 Deleting a Job The following deletes the job Remove old logs owned by root:./smcron delete -H myhost -u root -p mypassword -- \
-n "Remove old logs" -o root
Example 3 Listing Jobs in Native FormatThe following lists all jobs in native, or crontab(1), for-
mat:./smcron list -H myhost -u root -p mypassword -- -f n
MINUTE HOUR DATE MONTH DAY COMMAND 10 3 * * * /usr/sbin/logadm 15 3 * * 0 /usr/lib/fs/nfs/nfsfind1 2 * * * [ -x /usr/sbin/rtc ] && /usr/sbin/rtc -c > /dev/null 2>&1
30 3 * * * [ -x /usr/lib/gss/gsscred_clean ] && /usr/lib/gss/gsscred_clean
Example 4 Listing Jobs in Standard Format The following lists all jobs owned by lp in standard format:./smcron list -H myhost -u root -p mypassword -- -f s -o lp
NAME::OWNER::SCHEDULE::COMMAND
NoName_1765663371::lp::Weekly on Sundays at 3:13 AM::cd /var/lp/logs;
if [ -f requests ]; then if [ -f requests.1 ]; then /bin/mv requests.1
SunOS 5.11 Last change: 24 Mar 2003 8
System Administration Commands smcron(1M)
requests.2; fi; /usr/bin/cp requests requests.1; > requests; fiNoName_512822673::lp::Weekly on Sundays at 4:15 AM::cd /var/lp/logs;
if [ -f lpsched ]; then if [ -f lpsched.1 ]; then /bin/mv lpsched.1
lpsched.2; fi; /usr/bin/cp lpsched lpsched.1; >lpsched; fi Example 5 Listing jobs in verbose format The following lists all jobs in verbose format:./smcron list -H myhost -u root -p mypassword -- -f v
NAME::OWNER::SCHEDULE::NEXT_RUN::STATUS::COMMAND
NoName_1075488942::root::Advanced::::Finished on Feb 10 3:10 with code 1
::/etc/cron.d/logchecker databackup::root::Weekly on Sundays at 3:10 AM::3/19/00 3:10 AM ::Finished on Sep 19 3:10::/usr/lib/newsyslog runlog::root::Daily at 2:01 AM::3/14/00 2:01 AM::Finished on Feb 11 2:01 AM::/usr/sbin/rtc Example 6 Changing a Job The following modifies the job Remove old logs owned by root to execute daily at 2:00 AM:./smcron modify -H myhost -u root -p mypassword -- -n "Remove old logs" \
-o root -t 2:00
Example 7 Specifying Multiple Time Argumentssmcron allows you to specify a range of times for all of its
time-related subcommands, -m, -M, -t, and -w. For example,
the following command:# smcron add -u root -p xxxx -- -n cronjob1 -w 1-4,5 \
-t 12:00,13:15,14:30 -c ls
SunOS 5.11 Last change: 24 Mar 2003 9
System Administration Commands smcron(1M)
...creates the following entry in crontab:0,15,30 12,13,14 * * 1,2,3,4,6 ls #cronjob1
This job would run on Monday through Thursday and Saturday at the following times: 12:00 12:15 12:30 13:00 13:15 13:30 14:00 14:15 14:30 ENVIRONMENT VARIABLESSee environ(5) for a description of the JAVA_HOME environ-
ment variable, which affects the execution of the smcron
command. If this environment variable is not specified, the /usr/java location is used. See smc(1M). EXIT STATUS The following exit values are returned: 0 Successful completion. 1 Invalid command syntax. A usage message displays. 2 An error occurred while executing the command. An error message displays.ATTRIBUTES
See attributes(5) for descriptions of the following attri-
butes:____________________________________________________________
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
|_____________________________|_____________________________|
| Availability | SUNWmga ||_____________________________|_____________________________|
SEE ALSO
SunOS 5.11 Last change: 24 Mar 2003 10
System Administration Commands smcron(1M)
crontab(1), cron(1M), smc(1M), attributes(5), environ(5) NOTESThe timezone of the cron daemon sets the system-wide
timezone for cron entries. This, in turn, is by set bydefault system-wide using /etc/default/init.
If some form of daylight savings or summer/winter time is in effect, then jobs scheduled during the switchover period could be executed once, twice, or not at all.SunOS 5.11 Last change: 24 Mar 2003 11