Softpanorama

May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

Process Scheduling

News Recommended Links Recommended Books crontab cron SMF
at nice/renice priocntl uptime command Truss Etc

Solaris offers typical UNIX commands for process scheduling. Solaris 10 adds SMF facility for starting stopping processes that gives you capability to take extra advantage of resolving existing dependencies during starting or stopping of a particular process.

As in most Unixes crontab and at commands are used in Solaris for automatic execution of executables and scripts  at a scheduled time. In addition you can use the nice  and the renice  commands to alter the priority of running processes.

The crontab  Command

The crontab  files are stored in the /var/spool/cron/crontab  directory. Each crontab  command represents a scheduled task, which is known as a cron  job. Root and any user who has permissions to schedule events has his or her own crontab  file.

The structure of crontab did not changes from the times it was introduced. It contains six fields:

  1. Minute Minute of the hour (0-59)
  2. Hour Hour of the day (0-23)
  3. Day  Day of the month (1-31)
  4. Month  Month of the year (1-12)
  5. Weekday  Day of the week(0-6; 0=Sunday)
  6. Command The command to execute
By default, the /var/spool/cron/crontabs  directory contains the crontab  files for system accounts. The default crontab  files are adm  for accounting, lp  for printing, root  for administrative tasks, and sys  for performance collection

The cron daemon can be controlled using  /etc/default/cron  file. For example to log the activities of the cron  command, ensure the presence of the following entry:

CRONLOG=YES

This entry logs the activity of cron  in the /var/cron/log  file. To disable logging, modify this entry as follows:

CRONLOG=NO

You need to restart the cron to reread the file.

You can control users' access to the crontab  command by using the /etc/cron.d/cron.allow  and the /etc.cron.d/cron.deny  files.

In Solaris by default the cron.deny  file prohibits crontab  use by the following system users:

To create a crontab  file, use the -e  option of the crontab  command followed by the file name, for example:

# crontab -e joeuser

The -e  option is also used to edit an existing crontab  file.

The -l  option lists a crontab  file. The following example displays the lp crontab  file used for printing.

# crontab -l lp 

The -r  option is used to delete the crontab  file. 

Note: If you have accidentally typed the crontab  command without any arguments, exit with Ctrl+C. Exiting with Ctrl+D removes all entries in your crontab  file.

The at  command

The at  command schedules a single system event only once, unlike the crontab  command, which can schedule multiple system events repetitively at specified periods. The at  command enables users to create, display, and remove their own at  jobs.

To schedule at  jobs, type at followed by the time. After you type this, a prompt <at>  is displayed. Specify the command or script that has to execute at the specified time. The time is mentioned in minutes, hours, days, and months.

The following example shows how to remove the files from the home directory of user Jency at 9.55 p.m. on August 2.

$ at 9:55PM
at> rm /export/home/jency
at> rm /albert
at> mkdir / albert1
at> <EOT>
commands will be executed using /sbin/sh
job 996807300.a at Thu Aug  2 21:55:00 2001
$

NOTE: Type Ctrl+C to exit the at  prompt.

Each at  job is given a job ID and has a suffix of .a, which identifies it is an at  job. When more than one job is scheduled for execution, it is queued as per the time schedule. To display this queue, use the atq  command.

# atq
 Rank     Execution Date     Owner     Job         Queue   Job Name
  1st   Aug  2, 2001 21:55   root    996807300.a     a     stdin
  2nd   Aug 15, 2001 12:00   root    997894800.a     a     stdin
#

Options:

To display an at  job you should know its job ID. The at -l  command, without any arguments, displays the status information for all the at  jobs created by the user who executes the at -l  command.
$ at -l
user = root     996807300.a     Thu Aug  2 21:55:00 2001
user = root     997894800.a     Wed Aug 15 12:00:00 2001
$

The at -r  command followed by the job ID removes the at  job with the specified job ID.

# at -r <job id>

nice  and renice  commands

You can use the nice  command to alter the access priority of processes. The nice  number for a process can range from 0 to +40 with 0 indicating the highest priority and 40 indicating the lowest priority. To change the priority order of a process by using the nice  command, change the process's nice  number. For example, to increase the priority of a process by 10 units, decrease the nice  number by 10. The higher the value of nice, the lower is its execution priority.

Both the standard version and the /usr/bin/nice  version of the nice  command in Solaris use the following syntax:

/usr/bin/nice -[+ | -n] command_name

In the /usr/bin  version of the nice  command, the value to add or subtract from the nice  number is preceded by a hyphen. For example, to decrease the nice  number from 30 to 24, use the following syntax. Note that if no number is specified, the nice  number is increased by 10 by default, which decreases the priority value by 10 units.

/usr/bin/nice --6 command_name
 

Similarly, to increase the nice  number from 24 to 30, use the following syntax:

/usr/bin/nice -6 command_name
 

You can also change the priority of a process while the process is running. Solaris provides the renice  command, which you use to change the priority of an executing process. The renice  command takes the PID of the process as the operand. The command uses the following syntax:

renice [-n priority_change] PID
 

The -n  option in the preceding syntax defines the number of units by which to increase or decrease the priority of the running process. By default, all the processes running on the system are assigned a nice  value equal to 20. Note that after altering the priority of the running process, the new nice  value is 20 +/- the priority change. This value can range from 0 through 39. PID is the process ID for which the priority has to be changed.

For example, to decrease the priority of the process for PID 324 by 5 during runtime, use the following command:

renice -n 5 -p 324
 

In the preceding command, the new nice  value for the process will be 15.

You also can use the renice  command to change the priority of processes belonging to a particular user. For example, to increase the execution priority of processes belonging to the user David by 8 units, use the following command:

renice -n -8 -u David

The priocntl  command

The Solaris provides the priocntl  command, which you use to change the scheduling behavior of a process. The command displays or sets the priority of the processes. You can also use the priocntl  command to display the current configuration information of the process scheduler.

Table below lists the options of the priocntl  command:

The priocntl -l  command displays a list of the currently loaded scheduling classes. A sample output of the command follows.

# priocntl -l
CONFIGURED CLASSES
==================
SYS (System Class)
TS (Time Sharing)
        Configured TS User Priority Range: -60 through 60
IA (Interactive)
        Configured IA User Priority Range: -60 through 60
#
The priocntl -l  command displays the scheduling parameters of a process. A sample output of the command follows.
# priocntl -d -i pid 1
TIME SHARING PROCESSES:
    PID    TSUPRILIM    TSUPRI
     1            0                0
The priocntl -l  command creates a process. For example, the following command starts the find  command with a priority of 10.
# priocntl -e -c TS -p 10 find / -name core -print
In the preceding command, the -e  option executes the command. The -c  option specifies the class in which the command executes.

Truss

Solaris offers the truss utility that you use to track processes running on a system. The truss utility is similar to the trace utility of Solaris 4.x. The truss utility reports the following information about processes:

You use the truss utility to debug problems with processes. Although truss is not a debugging utility, it helps you identify problems a process encounters.

You can use the truss utility to track any executable command or a currently running process by using the PID value of the process. The truss utility tracks the child processes until the process exits. The truss utility uses the following syntax to track processes that are running on the system:

truss -aef -p PID

where PID is the process ID of a currently running process.

To use truss with an executable command, use the following syntax:

truss -aef <command>

Table below lists the commonly used options of the truss  command and their descriptions. For a complete list of options, refer to the man pages for the truss  command.

The truss Command Options and Their Descriptions
Option Description
-a Displays the arguments to each exec()  system call.
-c Displays a summary of all the system calls made by a process.
-e Displays the environment of a running process.
-f Follows all child processes created by the fork  and vfork  system calls.
-o Saves the output of the command to a specified file.
-p Attaches the truss  command to a currently running process.
 

By default, the truss utility dumps the output to the stderr  file. You can save the output of the truss utility by using the -o  option with the truss  command. For example, to save the output of the truss  command to the trussoutput.out  file use the following command:

truss -aef -o /tmp/trussoutput.out -p PID

Summary

Most processes in the system are created by fork system calls. The fork system call makes a copy (child process) of the calling process (parent process) in a new address space in the virtual memory. The child process continues to execute on the CPU until it completes. On completion, the child process returns the resources to the system.

A process during its lifetime can exist in any of the following states: Init, Run, Sleep, and Zombie.

Processes running on a system affect the performance of the system because processes consume system resources, such as CPU time and memory. Therefore, it is important that you manage the processes running on the system. Managing the processes running on the system involves monitoring processes, determining processor usage, changing process priorities, and terminating processes



Etc

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


Copyright © 1996-2021 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: March 12, 2019