crontab

schedule regular background jobs 

Command


SYNOPSIS

crontab [file]

crontab -e

crontab -l

crontab -r

crontab -s

crontab -u


DESCRIPTION

crontab creates or changes your crontab file. Your crontab file is a list of tasks that are run on a regular schedule. For example, you might set up your crontab file so that it runs a task every night or midnight, or once a week during low-use hours. This task could perform regular maintenance chores, for example, backing up files or getting rid of unnecessary work files.

Your crontab file is stored in the following directory:

$ROOTDIR/etc/scheduler/crontabs/user

where user is the local user name or the domain user name with a + in place of the \.

To set up a new crontab file, use

crontab file

If you omit the file argument, crontab takes input from the standard input.

Input consists of six fields, separated by blanks. The first five give a date and time in the following form:

Any of these fields may contain an asterisk * standing for all possible values. For example, if you have an * as the day of the month, the job runs every day of the month. A field can also contain a set of numbers separated by commas, or a range of numbers, with the first number followed by a minus sign - followed by the second number. If you give specific days for both day of the month and day of the week, the two are ORed together.

Here are some examples.

0 0 * * *          -- midnight every day
0 0 * * 1-5        -- midnight every weekday
0 0 1,15 * *       -- midnight on 1st and 15th
                      of month
0 0 1 * 5          -- midnight on 1st of month
                      and every Friday

The sixth field of a crontab entry is a string that your shell executes at the specified time.

If the string in your crontab entry contains percent characters %, they are interpreted as newline characters, splitting your string in several logical lines. You can include an actual % character in this string by escaping it with a backslash (\). The first logical line (up to the first unescaped %) is interpreted as the command you want to execute; subsequent logical lines are used as standard input to the command. If any real (not logical) line in the file is blank or begins with #, the shell ignores the line (treats it as a comment).

For each entry in the crontab file, crontab creates a task to be run by the Windows Task Scheduler using taskrun. The command portion of each entry will be executed using

$ROOTDIR/mksnt/sh.exe -c

Note:

Because crontab must create Windows Task Scheduler tasks for the entries listed in the crontab, there may be a significant pause while crontab creates these tasks.

On XP/2003/Vista/7/2008/8/2012 the mksauth authentication service is queried to get the current user's password. The task will be run using the current user name, the retrieved password, and the normal start-up environment for the user. If a password cannot be retrieved, the task is added with no user name and password. You must be in the administrator group to add tasks without having a password saved with the mksauth authentication service. Such tasks are run using the environment as it exists at the time of their execution.

On XP/2003/Vista/7/2008/8/2012, use passwd or rsetup to set your password for the mksauth service.

Common practice is to redirect the standard output and standard error from tasks to files so you can read the output after the tasks have completed. If you do not redirect the standard output or standard error, crontab e-mail these streams to you using smtpmail and/or write the streams to a log file depending on how the SHEDULER_MAILTO and SCHED_LOGFILE environment variables are set.

When SCHEDULER_MAILTO is set, its value is the e-mail address to which the standard output and standard error stream are sent using smtpmail.

Note:

You must have smtpmail properly set up on your system.

When SCHEDULER_LOGFILE is set, its value is the name of the log file to which the standard output and standard error streams are appended.

When both environment variables are set, the streams are both e-mailed and written to the log file. When neither environment variable is set, the streams are appended to the default log file $ROOTDIR/etc/scheduler/log/user, where user is the name of the user who scheduled the job. When user is a domain name, the \ in the name is replaced with a +.

When a task does not produce any output or errors, you are not normally informed of its completion.

Tasks created by crontab have names of the form:

MKS_WTS_user_currentdatetime

where user is the local user name or the domain user name with a + in place of the \.

Note:

Once a task name has been assigned to a task, you should not rename that task. Renaming tasks could cause possible problems with some utilities in the MKS Toolkit Scheduling Suite.

Options

-e 

lets you edit your crontab file. crontab invokes an editor to edit the file. If you have an EDITOR environment variable defined, crontab assumes that the variable's value is the name of the editor you want to use. If you do not have EDITOR defined, crontab uses vi.

If you do not have a crontab file, crontab creates one.

-l 

displays your current crontab file on the standard output.

-r 

removes (deletes) your current crontab file and removes the scheduled tasks from the Windows Task Scheduler. When a crontab file is removed using this option, it cannot be rebuilt using the -u.

-s 

synchronizes the list of scheduled tasks in the Windows Task Scheduler with the contents of your crontab file. This ensures that the Window Task Scheduler has a correct list of scheduled tasks and that those tasks are run using the correct environment.

Using this option is necessary for any changes in the SCHEDULER_LOGFILE and SCHEDULER_MAILTO environment variables to be applied to existing tasks.

This option is also useful if crontab's update of the Windows Task Scheduler is interrupted and the tasks are not added. Because the crontab file still exists, you can use this option to ensure that all crontab entries are added.

-u 

rebuilds a deleted crontab file from the remaining entries in the Windows Task Scheduler. This option does not work if the crontab file was removed with the -r option.


ENVIRONMENT VARIABLES

EDITOR 

specifies the editor that the -e option invokes. The default editor is vi.

SCHEDULER_MAILTO 

specifies the e-mail address to which smtpmail sends all mail generated by crontab.

SCHEDULER_LOGFILE 

specifies the log file to which information normally mailed is appended.

TK_UNIX_FILESYSTEM 

When this variable is set, the Enhanced UNIX Compatibility Mode is on and the virtual file system is in use.

When the Enhanced UNIX Compatibility Mode is on, all path names in the commands that you schedule should be Windows path names. In addition, information about a scheduled job (such as the working directory) is displayed using Windows path names.

For details on the Enhanced UNIX Compatibility Mode and the virtual file system, see the EUCM reference page.


DIAGNOSTICS

Possible exit status values are:

0 

Successful completion.

1 

Returned if the command fails for any reason. In this case, crontab does not change your crontab file in any way.


PORTABILITY

Windows XP. Windows Server 2003. Windows Vista. Windows 7. Windows Server 2008. Windows 8. Windows Server 2012.


AVAILABILITY

PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Commands:
at, mksauth, passwd, rsetup, smtpmail, taskrun

MKS Toolkit Scheduling Solutions Guide


PTC MKS Toolkit 9.6 patch 1 Documentation Build 5.