How to Calculating Free PE in HP-UX

Calculating free PE’s

vgdisplay -v <vgname> e.g. vg02

# vgdisplay -v vg02
— Volume groups —
VG Name                     /dev/vg02
VG Write Access             read/write
VG Status                   available
Max LV                      255
Cur LV                      1
Open LV                     1
Max PV                      16
Cur PV                      1
Act PV                      1
Max PE per PV               35004
VGDA                        2
PE Size (Mbytes)            8        —> 1 PE is  8 MB
Total PE                    17499
Alloc PE                    17400
Free PE                     99              —> free PE is 99
Total PVG                   0
Total Spare PVs             0
Total Spare PVs in use      0

8×99 = means 792 MB of space can be extended.

What is Shell Scripts

Shell scripts are text files that automate a series of UNIX environment-based commands that otherwise must be performed one at a time. Shell scripts are often used to automate command sequences that repeat, such as services that start or stop on system start up or shut down.

Any command that can be performed from the command line, such as ls, can be included in a shell script. Similarly, any command that can be included in a shell script can be performed on the UNIX environment command line.

Users with little or no programming experience can create and run shell scripts. You initiate the sequence of commands in the shell script by simply entering the name of the shell script on a command line.

Determining the Type of Shell to Run a Shell Script

There are several different shells available in the Solaris OS. Two of the most commonly used shells are the Bourne shell and the Korn shell.

To ensure that the correct shell is used to run a shell script, the first line of the script should always begin with the characters #!, followed immediately by the absolute path name of the shell required to run the script. These must be the only characters on the first line of the file.

#!/full-pathname-of-shell

For example:

#!/bin/sh

or

#!/bin/ksh

Comments

Comments are text entries that often provide information about a shell script. They are inserted into a shell script but have no effect on the script itself. Comments are ignored by the shell and are solely for the benefit of the user.

Comments are preceded by the hash (#) character. Whenever the shell encounters a word beginning with the # character it ignores all text on that line.

For example:

# this is a comment ls -l # list the files in a directory

Setting Korn Shell Options

Options are switches that control the behavior of the Korn shell. Options are boolean, meaning that they can be either on or off.

To switch an option on, type:

$ set -o option_name

To switch an option off, type:

$ set +o option_name

To show current option settings, type:

$ set -o
Note: The set -o and set +o options can only change a single option setting at a time.

Protecting File Content During I/O Redirection

Redirecting standard output to an existing file overwrites the previous file content, which results in data loss. This process of overwriting existing data is known as clobbering. To prevent an overwrite from occurring, the shell supports a noclobber option.

When the noclobber option is set, the shell refuses to redirect standard output to the existing file and displays an error message to the screen.

The noclobber option is activated in the shell using the set command. For example:

$ set -o noclobber
$ set -o | grep noclobber
noclobber        on
$ ps -ef > file_new
$ cat /etc/passwd > file_new
ksh: file_new: file already exists
$

Deactivating the noclobber Option

To temporarily deactivate the noclobber option, use the >| deactivation syntax on the command line. The noclobber option is ignored for this command line only, and the contents of the file are overwritten.

$ ls -l >| file_new

Note: There is no space between the > and | on the command line.

To deactivate the noclobber option, perform the following commands:

$ set +o noclobber $ set -o | grep noclobber
noclobber off
$ ls -l > file_new $

cron log is c queue max run limit reached

PROBLEM
cron jobs are being rescheduled and not running. The message in the cron log is c queue max run limit reached [date & time] rescheduling a cron job [date & time]

RESOLUTION

The error:

! c queue max run limit reached Fri May 27 12:39:00 2011
! rescheduling a cron job Fri May 27 12:39:00 2011
! c queue max run limit reached Fri May 27 12:39:00 2011
! rescheduling a cron job Fri May 27 12:39:00 2011

c queue max run limit reached [date & time]rescheduling a cron job [date & time],  corresponds to there being more than the maximum number of jobs running in the c queue than specified in “queuedefs”.

There was a problem with getspwent() which could cause the child cron processes to loop when they called getspwent().

HP-UX : 

EXAMPLE:

# cat /usr/lib/cron/queuedefs

a.4j1n
b.2j2n90w
c.100j1n

NOTE: The a queue, by default, can run 4 jobs simultaneously.

NOTE: The c.100j1n means 100 cron/at/batch jobs can be run similatenously with a nice value of 1.

To increase that number, modify the queuedefs file and restart cron.

The follow example increases the limit from 4 to 10 simultaneous jobs.

Modify the queuedefs file:

# vi /var/adm/cron/queuedefs

a.4j1n –> change this to the following line
a.10j1n

Stop Cron:

# ps -ef |grep cron

# kill {cron_pid}

NOTE: This defaults to a -15 which kills nicely.

Restart cron:

# /sbin/init.d/cron

rescheduling a cron job in solaris

Error :

! c queue max run limit reached Fri May 27 12:39:00 2011
! rescheduling a cron job Fri May 27 12:39:00 2011
! c queue max run limit reached Fri May 27 12:39:00 2011
! rescheduling a cron job Fri May 27 12:39:00 2011
! c queue max run limit reached Fri May 27 12:39:00 2011
! rescheduling a cron job Fri May 27 12:39:00 2011
! c queue max run limit reached Fri May 27 12:39:00 2011
! rescheduling a cron job Fri May 27 12:39:00 2011
! c queue max run limit reached Fri May 27 12:39:00 2011
! rescheduling a cron job Fri May 27 12:39:00 2011
! c queue max run limit reached Fri May 27 12:40:00 2011
! rescheduling a cron job Fri May 27 12:40:00 2011
! c queue max run limit reached Fri May 27 12:40:00 2011
! rescheduling a cron job Fri May 27 12:40:00 2011
! c queue max run limit reached Fri May 27 12:40:00 2011
! rescheduling a cron job Fri May 27 12:40:00 2011
! c queue max run limit reached Fri May 27 12:40:00 2011
! rescheduling a cron job Fri May 27 12:40:00 2011
! c queue max run limit reached Fri May 27 12:40:00 2011
! rescheduling a cron job Fri May 27 12:40:00 2011
! c queue max run limit reached Fri May 27 12:41:00 2011
! rescheduling a cron job Fri May 27 12:41:00 2011
! c queue max run limit reached Fri May 27 12:41:00 2011
! rescheduling a cron job Fri May 27 12:41:00 2011
! c queue max run limit reached Fri May 27 12:41:00 2011
! rescheduling a cron job Fri May 27 12:41:00 2011
! c queue max run limit reached Fri May 27 12:41:00 2011
! rescheduling a cron job Fri May 27 12:41:00 2011
! c queue max run limit reached Fri May 27 12:41:00 2011
! rescheduling a cron job Fri May 27 12:41:00 2011

Solaris :

Solution:

bash#  cat /etc/cron.d/queuedefs
a.9j1n
b.2j2n90w

NOTE: The a queue, by default, can run 4 jobs simultaneously.

NOTE: The a.9j1n means 9 cron jobs can be run similatenously with a nice value of 1.

To increase that number, modify the queuedefs file and restart cron.

The follow example increases the limit from 4 to 10 simultaneous jobs.

Modify the queuedefs file:

# vi /etc/cron.d/queuedefs

a.4j1n –> change this to the following line
a.10j1n

Stop Cron:

# ps -ef |grep cron

# kill {cron_pid}

NOTE: This defaults to a -15 which kills nicely.

Restart cron:

# svcadm restart cron

Solaris 9 or earlier versions Solaris 10
Service status ps(1) command
(only process information is shown)
svcs(1) or ps(1) command
Service stop # /etc/init.d/cron stop # svcadm disable -t
system/cron:default
Service restart (temporary) # /etc/init.d cron start # svcadm enable -t
system/cron:default
Service stop
After service restart the service isn’t started
(1)# /etc/init.d/cron stop
(2)# mv /etc/rc2.d/S75cron /etc/rc2.d/_S75cron
(Need to rename the service start script)
# svcadm disable -t
system/cron:default
Service restart (permanent) (1) # /etc/init.d/cron stop
(2) # /etc/init.d/cron start
# svcadm restart -t
system/cron:default


Using Korn Shell Functions

Functions are a powerful feature of shell programming used to construct customized commands. A function is a group of UNIX commands organized as separate routines. Using a function involves two steps:

  1. Define the function.
  2. Invoke the function.

Defining a Function

A function is defined using the general format:

function_name { command; . . . command; }
Note: A space must appear after the first brace and before the closing brace.

Function Examples

The following example creates a function called num to perform the who command, directing the output to the wc command to display the total number of users currently logged on the system:

$ function num { who | wc -l; }
$ num
	 9

The following example creates a function called list to perform the ls command, directing the output to the wc command to display the total number of subdirectories and files in the current directory:

$ function list { ls -al | wc -l; }
$ list
	 34
Note: If a command name is defined as a function and an alias, the alias takes precedence.

To display a list of all functions, use the following command:

$ typeset -f
function list
{
ls -al | wc -l; }
function num
{
who | wc -l; }

To display just the function names, use the following command:

$ typeset +f
list
num

Configuring the Shell Environment

The shell secondary prompt string is stored in the PS2 shell variable, and you can customize it as needed.

$ PS2="somethings missing >" $ echo $PS2 somethings missing > $ In this example, the secondary prompt displays the message that the command line is incomplete.
Note: To have this secondary shell prompt appear in every shell, it must be included in the user's Korn shell initialization file (usually named .kshrc).

Korn Shell Alias Utility

An alias is a shorthand notation in the Korn shell to enable you to customize and abbreviate UNIX commands. An alias is defined by using the alias command.

3>Command Format

The alias command syntax is as follows:

alias name=command_string

For example:

$ alias dir='ls -lF'

The shell maintains a list of aliases that it searches when a command is entered. If the first word on the command line is an alias, the shell replaces that word with the text of the alias. When an alias is created, the following rules apply:

  • There can be no space on either side of the equal sign.
  • The command string must be quoted if it includes any options, metacharacters, or spaces.
  • Each command in a single alias must be separated with a semicolon.

Predefined Korn Shell Aliases

The Korn shell contains several predefined aliases, which you can display by using the alias command. User-defined aliases are also displayed.

$ alias
autoload='typeset -fu'
command='command '
functions='typeset -f'
history='fc -l'
integer='typeset -i'
local=typeset
nohup='nohup '
r='fc -e -'
stop='kill -STOP'
suspend='kill -STOP $$'

User-Defined Aliases

Aliases are commonly used to abbreviate or customize frequently used commands. For example:

$ alias h=history $ $ h 278 cat /etc/passwd 279 pwd 280 cp /etc/passwd /tmp 281 ls ~ 282 alias h=history 283 h

Using the rm, cp, and mv commands can inadvertently result in loss of data. As a precaution, you can alias these commands with the interactive option.

For example:
$ alias rm='rm -i'
$ rm dat1
rm: remove  dat1: (yes/no)? no
$

By creating a cp -i and mv -i alias, the shell prompts you before overwriting existing files.

You can deactivate an alias temporarily by placing a backslash () in front of the alias on the command line. The backslash prevents the shell from looking in the alias list, thereby causing it to perform the original rm command.

For example:

$ rm file1 rm: remove file1 (yes/no)? no $ $ rm file1 $ ls file1 file1: No such file or directory

Command Sequences

You can group several commands together under a single alias name. Individual commands are separated by semicolons. For example:

$ alias info='uname -a; id; date' $ info SunOS host1 5.8 Generic sun4u sparc SUNW,Ultra-5_10 uid=102(user2) gid=10(staff) Fri Jun 30 15:22:47 MST 2000 $
In the next example, an alias is created using a pipe (|) to direct the output of the ls -l command to the more command. When the new alias is invoked, a directory listing appears. If the listing is longer than the available space on the screen, the --More-- line item appears at the end of the list, indicating that additional directory contents are displayed on the subsequent screen.

For example:

$ alias ll='ls -l | more' $ cd /usr $ ll total 136 drwxrwxr-x 2 root bin 1024 May 13 18:33 4lib drwx------ 8 root bin 512 May 13 18:14 aset drwxrwxr-x 2 root bin 7168 May 13 18:23 bin drwxr-xr-x 4 bin bin 512 May 13 18:13 ccs drwxrwxr-x 5 root bin 512 May 13 18:28 demo

Removing Aliases

Use the unalias command to remove aliases from the alias list. The unalias command syntax is as follows:
$ unalias alias_name

For example:

$ unalias h
$ h
ksh: h:  not found

Note: To pass the new aliases to every shell invoked, place it in your Korn shell initialization file (usually called .kshrc).

Other User Korn Shell Variables

Other Korn shell variables are described in the table.

Other Korn Shell Variables
Variable Use
LPDEST
Set your default printer. Use this value if using the /usr/bin/lp command.
PRINTER
Set your default printer. Use this variable if using the lpd-based compatibility commands (lpr, lpq, and lprm)
TERM,
Define the terminal. This variable should be reset in the /etc/profile file. When the user invokes an editor, the system looks for a file with the same name that is defined in this environment variable. The system searches the directory referenced by TERMINFO to determine the terminal characteristics.
MANPATD
Set the hierarchies of man pages that are available.

Managing Jobs in the Korn Shell

The Korn shell enables you to run jobs in the background, which frees your terminal to perform other commands. You can also run jobs in the foreground. You can use Korn shell commands to list current jobs as well as to stop a job.

A job is a process that the shell can manage. Shells start and control jobs. Because jobs are processes, each job has an associated PID. The shell also assigns each job a sequential job ID number.

The shell enables you to run multiple jobs at the same time. Job control commands enable you to manage multiple jobs within a shell. There are three types of jobs that shells manage: foreground jobs, background jobs, and stopped jobs.

When you perform a command in a terminal window, the command occupies that terminal window until it completes. This type of job is called a foreground job.

When you enter an ampersand (&) symbol at the end of a command line, the command runs without occupying the terminal window. The shell prompt is displayed immediately after you press Return. This type of job is called a background job.

If you press Control-Z for a foreground job, or perform the stop command for a background job, the job stops. This job is called a stopped job.

Job control commands enable you to place jobs in the foreground or background, and to start or stop jobs. The table describes the commands you can use for job control.

Job Control Commands
Command Value
jobs
Lists all jobs that are currently running or are stopped in the background
bg %n
Runs the current or specified job in the background (n is the job ID)
fg %n
Brings the current or specified job into the foreground (n is the job ID)
Control-Z
Stops the foreground job and places it in the background as a stopped job
stop %n
Stops a job that is running in the background (n is the job ID)


Note: You can control a job by using these commands only in the shell in which the job started.

Running a Job in the Background

To run a job in the background, enter the command you want to run along with an ampersand (&) symbol at the end of the command line. For example, you can run the sleep command in the background as follows:

$ sleep 500 &
[1]     3028
$
Note: The sleep command suspends execution of a program for n seconds.

The shell returns the job ID number it assigned to the command, contained in brackets, and the PID associated with the command. You use the job ID number to manage the job with job control commands. The kernel can use the PID number to manage the job.

When a background job has finished and you press Return, the shell displays a message indicating that the job is done.

[1] + Done
sleep 500 &
$

Listing Current Jobs

 You can use the jobs command to display the list of jobs that are running or stopped in the background. For example:$ jobs
[1] + Running
sleep 500 &
$

Bringing a Background Job Into the Foreground

 You can use the fg command to bring a background job to the foreground. For example:


$ fg %1
sleep 500

Note: The foreground job occupies the shell until the job is completed, stopped, or stopped and placed into the background.


Sending a Foreground Job to the Background

You can use the Control-Z keys and bg command to return a job to the background. The Control-Z keys suspend the job, and place it in the background as a stopped job. The bg command runs the job in the background. For example:

$ sleep 500
^Z[1] + Stopped (SIGTSTP)        sleep 500
$ jobs
[1] + Stopped (SIGTSTP)        sleep 500
$ bg %1
[1]     sleep 500&
$ jobs
[1] +  Running                 sleep 500
$

Note: When you place a stopped job in either the foreground or the background the job restarts.

command1 $(command2)

To ignore the special meaning of the dollar sign metacharacter, use the following command:

$ echo '$SHELL'
$SHELL


How can I determine the CPU Speed / Processors / Machine Serial Number in AIX server?

bash-3.00# prtconf


System Model: IBM,9133-55A
Machine Serial Number: 02346C5H
Processor Type: PowerPC_POWER5
Number Of Processors: 4
Processor Clock Speed: 1648 MHz
CPU Type: 64-bit
Kernel Type: 64-bit
LPAR Info: 1 06-86C6H
Memory Size: 15936 MB
Good Memory Size: 15936 MB
Platform Firmware level: Not Available
Firmware Version: IBM,SF240_338
Console Login: enable
Auto Restart: true
Full Core: false

Network Information
Host Name: gmacaix1
IP Address: 10.10.10.1
Sub Netmask: 255.255.255.0
Gateway: 10.10.1.45
Name Server:
Domain Name:

Paging Space Information
Total Paging Space: 31744MB
Percent Used: 3%

Volume Groups Information
==============================================================================
rootvg:
PV_NAME           PV STATE          TOTAL PPs   FREE PPs    FREE DISTRIBUTION
hdisk0            active            794         636         148..30..140..159..159
==============================================================================

INSTALLED RESOURCE LIST

The following resources are installed on the machine.
+/- = Added or deleted from Resource List.
*   = Diagnostic support not available.

Model Architecture: chrp
Model Implementation: Multiple Processor, PCI bus

+ sys0                                               System Object
+ sysplanar0                                         System Planar
* vio0                                               Virtual I/O Bus
* vsa1             U787B.001.DNWG8CW-P1-T2           LPAR Virtual Serial Adapter
* vty1             U787B.001.DNWG8CW-P1-T2-L0        Asynchronous Terminal
* vsa0             U787B.001.DNWG8CW-P1-T1           LPAR Virtual Serial Adapter
* vty0             U787B.001.DNWG8CW-P1-T1-L0        Asynchronous Terminal
* pci2             U787B.001.DNWG8CW-P1              PCI Bus
* pci8             U787B.001.DNWG8CW-P1              PCI Bus
+ ent0             U787B.001.DNWG8CW-P1-T9           2-Port 10/100/1000 Base-TX PCI-X Adapter (14108902)
+ ent1             U787B.001.DNWG8CW-P1-T10          2-Port 10/100/1000 Base-TX PCI-X Adapter (14108902)
* pci9             U787B.001.DNWG8CW-P1              PCI Bus
+ usbhc0           U787B.001.DNWG8CW-P1              USB Host Controller (33103500)
+ usbhc1           U787B.001.DNWG8CW-P1              USB Host Controller (33103500)
* pci10            U787B.001.DNWG8CW-P1              PCI Bus
* pci11            U787B.001.DNWG8CW-P1              PCI Bus
* pci1             U787B.001.DNWG8CW-P1              PCI Bus
* pci3             U787B.001.DNWG8CW-P1              PCI Bus
+ sisioa0          U787B.001.DNWG8CW-P1              PCI-X Dual Channel U320 SCSI RAID Adapter
+ scsi0            U787B.001.DNWG8CW-P1-T14          Ultra320 SCSI RAID Adapter Physical bus
+ pdisk1           U787B.001.DNWG8CW-P1-T14-L3-L0    Physical SCSI Disk Drive
+ pdisk2           U787B.001.DNWG8CW-P1-T14-L4-L0    Physical SCSI Disk Drive
+ pdisk3           U787B.001.DNWG8CW-P1-T14-L5-L0    Physical SCSI Disk Drive
+ pdisk0           U787B.001.DNWG8CW-P1-T14-L8-L0    Physical SCSI Disk Drive
+ ses0             U787B.001.DNWG8CW-P1-T14-L15-L0   SCSI Enclosure Services Device
+ scsi1            U787B.001.DNWG8CW-P1-T15          Ultra320 SCSI RAID Adapter Physical bus
+ sisraid0         U787B.001.DNWG8CW-P1-C7-T1        Ultra320 SCSI RAID Adapter Logical bus
* hdisk0           U787B.001.DNWG8CW-P1-C7-T1-L0-L0  SCSI RAID 5 Disk Array
* pci5             U787B.001.DNWG8CW-P1              PCI Bus
+ fcs1             U787B.001.DNWG8CW-P1-C4-T1        FC Adapter
* fscsi1           U787B.001.DNWG8CW-P1-C4-T1        FC SCSI I/O Controller Protocol Device
* fcnet1           U787B.001.DNWG8CW-P1-C4-T1        Fibre Channel
Network Protocol Device
* pci4             U787B.001.DNWG8CW-P1              PCI Bus
* ide0             U787B.001.DNWG8CW-P1-T16          ATA/IDE Controller Device
+ cd0              U787B.001.DNWG8CW-P4-D2           IDE DVD-ROM Drive
* pci6             U787B.001.DNWG8CW-P1              PCI Bus
* pci7             U787B.001.DNWG8CW-P1-C5           PCI Bus
+ lai0             U787B.001.DNWG8CW-P1-C5-T1        GXT135P Graphics Adapter
* pci0             U787B.001.DNWG8CW-P1              PCI Bus
+ fcs0             U787B.001.DNWG8CW-P1-C3-T1        FC Adapter
* fscsi0           U787B.001.DNWG8CW-P1-C3-T1        FC SCSI I/O Controller Protocol Device
* fcnet0           U787B.001.DNWG8CW-P1-C3-T1        Fibre Channel Network Protocol Device
+ L2cache0                                           L2 Cache
+ mem0                                               Memory
+ proc0                                              Processor
+ proc2                                              Processor
+ proc4                                              Processor
+ proc6                                              Processor
* mouse0           U787B.001.DNWG8CW-P1-T7-L1        USB mouse
* kbd0             U787B.001.DNWG8CW-P1-T7-L1        USB keyboard