MAINFRAME > Administrator > Systems Management

Schedule Tasks Using Cron and REXX

Scheduling a certain task at a particular time or periodically is one of the important re-sponsibilities that administrators do. Frequently, specialized products are required to achieve such objectives. However, not all installations have the budget for such products.

Fortunately, there are ways to schedule tasks using only z/OS and its base features, rather than specialized products. Instead, you can schedule such tasks using the cron daemon (referred to as cron) and simple REXX scripts.

Cron and REXX

Cron is a time-based scheduler available with z/OS UNIX System Services (USS). It can schedule tasks at a specified time or periodically. It’s not a new feature of z/OS but has existed a long time. Defining scheduled tasks using the cron daemon can be done with commands like, at, batch and crontab.

Because cron and REXX execs can complement each other, the task or activity you want to achieve can be packaged into a REXX exec, and cron can simply schedule the execu-tion of REXX at a particular time.

Setting up Cron

You must first set up cron before it can do work for you. This involves creating the re-quired directories and files for its function, and customizing certain configuration files. The queue definition file is where you set the performance goals for your cron daemon. The following example shows a sample queue definition file that needs to be placed un-der /usr/lib/cron/queuedefs.

# Sample queue definition file


# Queue name is a single character
# Default queue for at is 'a', for batch is 'b', and 'c' for crontab
# [These defaults can be customized]

# #j is the max number of jobs to run simultaneously in that queue
# [Set this to the appropriate value for your installation.]

# #n is the nice value for non-super user jobs in that queue
# [The nice value mapped to the PRIORITYGOAL or PRIORITYPG statement 
in BPXPRMxx] # #w is the # of seconds to wait before rescheduling. For example: # 5w: If five jobs are already running, wait 5 seconds before trying
the next job.

Unless your user id is listed in the cron access list under the /usr/lib/cron/ directory, you might require super-user authority to use the cron features.

Allowed users list	: /usr/lib/cron/cron.allow
Denied users list	: /usr/lib/cron/cron.deny

You can create an empty cron.allow or cron.deny file to allow or deny all users, respec-tively.

With these configurations in place, the cron daemon is ready to be used. Usually, it will be started as a background process from /etc/rc as shown here:

_BPX_JOBNAME=CROND /usr/sbin/cron &

# & at the end, start the command in background
# _BPX_JOBNAME environment variable assigns a job name to the cron daemon

Arunkumaar Ramachandran is a Senior IT Specialist at IBM India Software Labs. His areas of expertise include z/OS and z/VM. Arunkumaar can be reached at

Senthil Balasundarm is an IT specialist with IBM. He has more than five years of experience in System z and z/OS.

comments powered by Disqus



2019 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

Active Energy Manager Pulls Resources Together

Integration with InfraStruXure Centeral provides single management interface.

Amplifying Your Energy Efficiency

IBM BladeCenter and virtualization team up for greener data centers

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
Mainframe News Sign Up Today! Past News Letters