Admin Alert: Using OS/400 Autostart Jobs for Repetitious Server Processing
by Joe Hertvik
Most OS/400 shops have a need to run permanent server jobs that handle repetitious processing requests for system users. These jobs need to start whenever an OS/400 subsystem servicing a specific workload begins; they answer user processing requests, and they always need to be running. Fortunately, IBM provides an autostart jobs feature that is useful for creating and running OS/400-based server jobs.
As the name implies, autostart jobs are attached to specific OS/400 subsystems and they start automatically whenever their associated subsystem is started, which makes them perfect candidates to run subsystem initialization jobs. They can also perform repetitive work or function as a communication, subsystem, or software server.
You need two things to attach an autostart job to a subsystem: a job description that describes the job parameters and the processing environment the job runs in; and an autostart job entry to attach to your target subsystem.
For an autostart job, a job description contains all the runtime environment parameters needed to run the job. Job descriptions are created on the green screen by running the Create Job Description command (CRTJOBD). While CRTJOBD contains too many parameters to cover in this article, the following critical parameters must be entered in order to successfully run your job:
- Job Queue (JOBQ): This parameter must equal one of the job queues associated with the subsystem the autostart job will run in.
- Routing data (RTGDTA): For most autostart job descriptions, the routing data field should contain the 'QCMDI' literal, which tells OS/400 to run the command string by using the OS/400 command processor program, QCMD.
- Request Data or Command (RQSDTA): Here you put in the actual command string that OS/400 should execute in order to run your program. This can be a standard Call Program command (CALL), another CL command, or an API program.
- Initial Library List (INLLIBL): Here you enter the library list that your server job uses while it executes the requested command.
There are other parameters that you can define for your autostart job description, but these are the critical pieces. Given this, a typical CRTJOBD command for creating an autostart job might look like this:
CRTJOBD JOBD(library/job description name) JOBQ(library/job_queue_name) RTGDTA(QCMDI) RQSDTA('command_string') INLLIBL(library1 library2)
Once the job description is created, it is a simple matter to create an autostart job entry that attaches the job description to your subsystem description, so that the job is autostarted whenever the subsystem is started. You can add an autostart job entry to a subsystem by using the Add autostart Job Entry command (ADDAJE), like this:
ADDAJE SBSD(library /subsystem name) JOB(job_name) JOBD(library/job description name)
Where each parameter defines the following features of an autostart job:
- Subsystem Description (SBSD): Defines the subsystem description name and library location of the subsystem you want to attach your autostart job to.
- Job Name (JOB): The name you want to give the autostart job while it is running in your subsystem.
- Job Description (JOBD): The job description that contains all the runtime parameters necessary to execute the autostart job.
After the ADDAJE command runs successfully, you will have added an autostart job entry to your target subsystem. Whenever the target subsystem is started, the autostart job described in this entry will launch and run in that subsystem. autostart job entries for a subsystem can be displayed by running the Display Subsystem Description command (DSPSBSD), as shown below, and selecting option 3, Autostart Job Entries, from the menu that appears:
DSPSBSD SBSD(library /subsystem name)
To change an autostart job entry, enter the Change Autostart Job Entry command (CHGAJE) as follows, and press the F4 key to change any of the parameters:
CHGAJE SBSD(library /subsystem name) JOB(job_name) JOBD(library/job description name)
To remove an autostart job entry from a subsystem, use the Remove Autostart Job Entry, like this:
RMVAJE SBSD(library /subsystem name) JOB(job_name)
If you are using an autostart job for subsystem initialization, where the program will run a predetermined number of steps and then terminate, you won't run into many problems. However, if you are using an autostart job as a server job where it will handle multiple requests over a long period of time when the subsystem is running, you may need to restart the job occasionally to reinitialize job parameters. The problem with autostart jobs is that the only way to restart each job is to end and restart the subsystem that runs the job. Because of this, you may want to schedule occasional subsystem restarts in order to refresh your autostart server jobs.
For more information on autostart jobs, see IBM's write-up on the subject in the iSeries Information Center.
Click here to contact Joe Hertvik by e-mail.