Samples SAS     hardening SAS     operational use SAS     DTAP design
Concepts    Solutions    Add doc    top  bottom

Scheduling with Cron

archive
Scheduling Solution
Cron Crontab or equivalent is standard available.
A simple timed start of processes without dependicies is possible.
Using the an non personalized key can be requried by policies. In this case is the question how the users should act tot their schedule requests.



Concepts

Cron Crontab

Background Information:
Is a standard component of the OS. Alternatives in some OS-variants is possible. The running project should already have: The only problem in sas to be solved is extending the scheduling with sas sources to be placed by business users.
New Operational problems like: Not Solved problems:


Conclusion:
This approach is able to fullfill requirements in a simple running sas programs when not at work.
Implementations:
(to come)



Start of applicaton environment

Background Information:
A batch script with all libnames filenames and outher settings must be present for the users.
Detail design:
(to come)
New Operational problems like:

Not Solved problems:


Conclusion:
This approach is ready to be used.
Implementations:
(to come)



SAS Selection sources

Background Information:
(to come)
Detail design:
(to come)
New Operational problems like:

Not Solved problems:


Conclusion:
This approach is nice but not ready yet using in secure environments.
Implementations:
(not available)



Concepts    Solutions    Add doc    top  bottom

Solutions

Export display x11



#!/bin/ksh

export DISPLAY=$(who am i | cut -d "(" -f 2 | cut -d ")" -f 1):0
export PATH=.:/prj/bi/infra/code/instsup/cur:${PATH}
echo DISPLAY:=$DISPLAY
echo PATH:=$PATH
echo .......

# ln -s /prj/bi/infra/code/instsup/cur/.profile_bi.ksh ${HOME}/.profile_bi

Crontab definitions

Daily and weekly timed


# sudo -u nkrcr_bd
# rcr support Cron
#
#
45 06 * * 1-5 /usr/local/sas/batch/sasappl rcr{b} k '\%xsch00m0(,rcr,b,rcrSch,, d06* , od06* );';
45 12 * * 1-5 /usr/local/sas/batch/sasappl rcr{b} k '\%xsch00m0(,rcr,b,rcrSch,, d12* , od12* );';
45 21 * * 1-5 /usr/local/sas/batch/sasappl rcr{b} k '\%xsch00m0(,rcr,b,rcrSch,, d21* , od21* );';
45 01 * * 2-6 /usr/local/sas/batch/sasappl rcr{b} k '\%xsch00m0(,rcr,b,rcrSch,, d01* , od01* );';
#
45 22 * * 5 /usr/local/sas/batch/sasappl rcr{b} k '\%xsch00m0(,rcr,b,rcrSch,, w22* , ow22* );';
45 13 * * 6 /usr/local/sas/batch/sasappl rcr{b} k '\%xsch00m0(,rcr,b,rcrSch,, w13* , ow13* );';
45 19 * * 0 /usr/local/sas/batch/sasappl rcr{b} k '\%xsch00m0(,rcr,b,rcrSch,, w19* , ow19* );';


Crontab
== The timed definitions are:
    6:45 12:45 21:45 and 01:45 every working day.
    22:45 (sa), 13:45 (su), 19:45 (su) every week.
== The job to run is everytime the same unix-script. It is starting sas, with some parameters, and as source a sas-macro xsch00m0 with parameters.

SAS macro xsch00m0
It has several parameters:



SAS appl script (ksh)

(to come)



SAS macro / data step selections

(to come)

(to come) Macro Code:



Concepts    Solutions    Add doc    top  bottom

Additonal documentation

The following is a copy from man crontab (IBM AIX).

crontab Command

Purpose
Submits, edits, lists, or removes cron jobs.

Syntax crontab [ -e [UserName] | -l [UserName] | -r [UserName] | -v [UserName] | File ]

Description The crontab command submits, edits, lists, or removes cron jobs. A cron job is a command run by the cron daemon at regularly scheduled intervals. To submit a cron job, specify the crontab command with the -e flag. The crontab command invokes an editing session that allows you to create a crontab file. You create entries for each cron job in this file. Each entry must be in a form acceptable to the cron daemon. For information on creating entries, see The crontab File Entry Format.

When you finish creating entries and exit the file, the crontab command copies it into the /var/spool/cron/crontabs directory and places it in a file named for your current user name. If a file with your name already exists in the crontabs directory, the crontab command overwrites it.

Alternatively, you can create a crontab file by specifying the File parameter. If the file exists, it must be in the format the cron daemon expects. If the file does not exist, the crontab command invokes the editor. If the EDITOR environment variable exists, the command invokes the editor it specifies. Otherwise, the crontab command uses the vi editor.

To list the contents of your crontab file, specify the crontab command with the -l flag. To remove an existing file, use the -r flag.

The optional UserName parameter can be used by the owner of the crontab file or by the root user to edit, list, remove, or verify the status of the cron jobs for the specified user. If the UserName is invalid, an error message is generated and the program exits.

If the optional UserName parameter is not specified, the crontab flags are available for the root user and the current user.

Security
Only the root user or the owner of the crontab file can use UserName following the -e, -l, -r, and -v flags to edit, list, remove, or verify the crontab file of the specified user.

The cron Daemon

The cron daemon runs commands according to the crontab file entries. Unless you redirect the output of a cron job to standard output or error, the cron daemon mails you any command output or errors. If you specify a cron job incorrectly in your crontab file, the cron daemon does not run the job.

The cron daemon examines crontab files only when the cron daemon is initialized. When you make changes to your crontab file using the crontab command, a message indicating the change is sent to the cron daemon. This eliminates the overhead of checking for new or changed files at regularly scheduled intervals.

Controls on Using the crontab Command

The /var/adm/cron/cron.allow and /var/adm/cron/cron.deny files control which users can use the crontab command. A root user can create, edit, or delete these files. Entries in these files are user login names with one name to a line. If your login ID is associated with more than one login name, the crontab command uses the first login name that is in the /etc/passwd file, regardless of which login name you might actually be using. Also, to allow users to start cron jobs, the daemon attribute in the /etc/security/user file should be set to TRUE , using the chuser command.

The following is an example of an cron.allow file:
If the cron.allow file exists, only users whose login names appear in it can use the crontab command. The root user's log name must appear in the cron.allow file if the file exists. A system administrator can explicitly stop a user from using the crontab command by listing the user's login name in the cron.deny file. If only the cron.deny file exists, any user whose name does not appear in the file can use the crontab command.

A user cannot use the crontab command if one of the following is true: If neither the cron.allow nor the cron.deny file exists, only someone with root user authority can submit a job with the crontab command.

The crontab File Entry Format
A crontab file contains entries for each cron job. Entries are separated by newline characters. Each crontab file entry contains six fields separated by spaces or tabs in the following form:
minute hour day_of_month month weekday command


These fields accept the following values:
You must specify a value for each field. Except for the command field, these fields can contain the following:
Note: Any character preceded by a backslash (including the %) causes that character to be treated literally. The specification of days may be made by two fields (day of the month and day of the week). If you specify both as a list of elements, both are adhered to. For example, the following entry:
0 0 1,15 * 1 command

would run command on the first and fifteenth days of each month, as well as every Monday. To specify days by only one field, the other field should contain an * .

Specifying Commands
The cron daemon runs the command named in the sixth field at the selected date and time. If you include a % (percent sign) in the sixth field, the cron daemon treats everything that precedes it as the command invocation and makes all that follows it available to standard input, unless you escape the percent sign (\%). Blank lines and lines whose first non-blank character is the number sign (#) will be ignored. If the arguments to the command have a backslash (´\´), the backslash should be preceded by another backslash.

Note: The shell runs only the first line of the command field. All other lines are made available to the command as standard input.

The cron daemon starts a subshell from your HOME directory. If you schedule a command to run when you are not logged in and you want commands in your .profile file to run, the command must explicitly read your .profile file.

The cron daemon supplies a default environment for every shell, defining HOME, LOGNAME, SHELL (=/usr/bin/sh), and PATH (=/usr/bin).

Flags


Security
Auditing Events: If the auditing subsystem has been properly configured and is enabled, the crontab command generates the following audit record (event) every time the command is run: See Setting up Auditing in Security for more details about how to properly select and group audit events, and how to configure audit event data collection.

Exit Status
This command returns the following exit values:

Examples
  1. To copy a file called mycronjobs into the /var/spool/cron/crontabs directory, enter the following:
    crontab mycronjobs The file will be copied as: /var/spool/cron/crontabs/ where is your current user name.
  2. To write the time to the console every hour on the hour, enter:
    0 * * * * echo The hour is `date` . >/dev/console
  3. To run the calendar command at 6:30 a.m. every Monday, Wednesday, and Friday, enter:
    30 6 * * 1,3,5 /usr/bin/calendar
  4. To run the calendar command every day of the year at 6:30, enter the following:
    30 6 * * * /usr/bin/calendar
  5. To run a script called maintenance every day at midnight in August, enter the following:
    0 0 * 8 * /u/harry/bin/maintenance
  6. To define text for the standard input to a command, enter:
    0 16 * 12 5 /usr/sbin/wall %HAPPY HOLIDAY! %Remember to turn in your time card.
    The text following the % (percent sign) defines the standard input to the wall command as: HAPPY HOLIDAY!
    Remember to turn in your time card.


Files
  1. /var/adm/cron/FIFO
    A named pipe that sends messages to the cron daemon when new jobs are submitted with the crontab or at command.
  2. /var/spool/cron/crontabs
    Specifies the crontab spool area.
  3. /var/adm/cron/cron.allow
    Specifies a list of users allowed access to the crontab command.
  4. /var/adm/cron/cron.deny
    Specifies a list of users denied access to the crontab command.


Related Information
The auditpr command, sh command, wall command.
The cron daemon.
The Auditing Overview in Security explains more about audits and audit events.




Concepts    Solutions    Add doc    top  bottom
Samples SAS     hardening SAS     operational use SAS     Dtap design

© 2006 J.A.Karman (02 may 2012)