Chapter 1. Linux Kernel Jobs

This chapter describes Linux kernel jobs and contains the following sections:

Linux Kernel Job Overview

Work on a machine is submitted in a variety of ways, such as an interactive login, a submission from a workload management system, a cron job, or a remote access such as rsh, rcp, or array services. Each of these points of entry creates an original shell process and multiple processes flow from that original point of entry.

Job initiators can be categorized as either interactive or batch processes.

The Linux kernel job, used by the Comprehensive System Accounting (CSA) software, provides a means to measure the resource usage of all the processes resulting from a point of entry. A job is a group of related processes all descended from a point-of- entry process and identified by a unique job ID. A job can contain multiple process groups, sessions, or array sessions and all processes in one of these subgroups are always contained within one job.

The job container can be used stand-alone. The batch scheduler LSF, for example, uses jobs directly to keep track of the collection of processes that make up a single batch scheduler request.

Figure 1-1, shows the point-of-entry processes that initiate the creation of jobs.

Figure 1-1. Point-of-Entry Processes

Point-of-Entry Processes

A Linux job has the following characteristics:

  • A job is an inescapable container. A process cannot leave the job nor can a new process be created outside the job without explicit action, that is, a system call with root privilege.

  • Each new process inherits the job ID from its parent process.

  • All point-of-entry processes (job initiators) create a new job.

  • The job initiator performs authentication and security checks.

  • Job initiation on Linux is performed via a Pluggable Authentication Module (PAM) session module.


    Note: PAMs are a suite of shared libraries that enable the local system administrator to choose how applications authenticate users. For more information on PAM, see the Linux Configuration and Operations Guide.


  • Not all processes on a system need to be members of a job.

    The process-control initialization process ( init(8)) and startup scripts called by init are not part of a job and have a job ID of zero.

For more information on jobs, see job(7) man page.


Note: The existing command jobs(1) applies to shell "jobs" and it is not related to the Linux kernel module jobs. The at(1), atd(8), atq(1), batch(1), atrun(8), and atrm(1) man pages refer to shell scripts as a job.


You can use the jstat(1) command to display job status information. The jwait(1) command waits for the job whose job ID is defined by the jid parameter and reports its termination status. The termination status is determined based upon the last process to exit the job. The root user can wait on any process on the system. All other users can only wait on jobs that they own. The jkill(1) command sends the specified signal to the processes contained in the job(s) identified by the jid(s). If no signal is specified, the TERM signal is sent. The TERM signal will kill processes which do not catch this signal. For other processes, if may be necessary to use the KILL (9) signal, since this signal cannot be caught. For more information on these job commands, see the appropriate man page.

In SLES10, the crond daemon is Pluggable Authentication Modules (PAM) aware. The /etc/pam.d/crond file is for PAM and crond.

You can add the pam_job.so to the crond file. If you want to control all entry points at the same time, you can use the common-session PAM file. The common-session PAM configuration file is included in most PAM configurations and includes login, crond, sshd, and so on. For more information, see the /usr/share/doc/packages/job/README file.

Job Library

The job_create library call is part of the job library that allows processes to manipulate and obtain status about Linux jobs. When the job library is to be used, the job.h header file should be included to obtain the proper definitions.

The syntax of the job_create call is, as follows:

#include <job.h>

jid_t job_create( jid_t jid_requested, uid_t uid, int options );

The job_create call creates a new job and attaches the calling process to the new job.

The jid_requested parameter allows the caller to specify ajid value to use when creating the job. If the caller wants the system to generate the job ID, then set jid_requested to 0. The uid parameter is used to supply the user ID value for the user that will own the job. For more information, see the job_create(3) man page.

The following routines are part of the job library:

Library Routine 

Description

job_detachjid(3) 

Detaches all the processes from a job

job_detachpid(3) 

Detaches a process from its current job

job_getjid(3) 

Returns the job ID for the given process

job_getjidcnt(3) 

Returns the number of jobs currently on the system

job_getjidlist(3) 

Gets the jids of the currently active job

job_getpidcnt(3) 

Gets the number of processes attached to a job

job_getpidlist(3) 

Gets the list of process pids attached to a job

job_getprimepid(3) 

Gets the prime process pid for a job

job_getuid(3) 

Gets the user ID of a job

job_killjid(3) 

Sends a kill signal to all processes in a job

job_sethid(3) 

Allows processes to manipulate and obtain status about Linux jobs.

job_waitjid(3) 

Waits for a job to complete

For more information about these job library routines, see the appropriate man page.

Installing and Configuring Linux Kernel Jobs for Use with CSA

Linux kernel jobs are part of the kernel on your SGI ProPack for Linux system. To configure jobs for services, such as Comprehensive System Accounting (CSA), perform the following steps:

  1. Change to the directory where the PAM configuration files reside by entering the following:

    cd /etc/pam.d

  2. To enable job creation for all session services add an entry to the /etc/pam.d/login file.

    If you want to enable jobs only for certain PAM services you can update individual configuration files. This example shows the login configuration file being changed. You customize PAM services by adding the session line to PAM entry points that will create jobs on your system, for example, login, rlogin, rsh, and su.

    To enable job creation for login users by adding this entry to the login configuration file:

    session   required    /lib/security/pam_job.so

  3. To configure jobs to be started automatically during system startup, use the chkconfig(8) command as follows:

    chkconfig --add job

  4. To stop jobs from being started automatically during system startup, use the chkconfig(8) command as follows:

    chkconfig --del job