Sponsored Content
Top Forums Programming performing a task at regular intervals Post 89506 by *nix on Monday 14th of November 2005 03:00:11 AM
Old 11-14-2005
UNIX supports about 30 signals, each with a unique integer code. You can program the current process to react to a particular signal in one of these ways.

React according to the default, which is to terminate, do nothing, or possibly dump core
Ignore the signal
Execute a user-supplied signal handler function

In addition, you can program the current process to block certain signals. Blocked signals are queued and only delivered if they are unblocked.

If you want a reminder of a timeout you can set the SIGALRM signal to the current process. Write a signal handler for the same and perform your operations there.

However there are two ways of implementing UNIX signal. SYSV and BSD style. The BSD style is more efficient.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Date Intervals

I posted a question on date intervals about a month back asking about how I could be able to go about a user entering the starting year/month/day and an ending year/month/day and then the script automatically cycling through each day of each month of each year that the user has specified. I... (7 Replies)
Discussion started by: yongho
7 Replies

2. Shell Programming and Scripting

mailing myself at regular intervals...

hi all, i wrote a script to mail myself using pine (modified) to keep remind of b'days. #!/bin/bash grep "`date +%D |awk -F/ '{print $2+1, $1+0}'`" dataFile >/home/username/mailme if test -s /home/username/mailme then pine -I '^X,y' -subject "Birthday Remainder" username... (4 Replies)
Discussion started by: timepassman
4 Replies

3. Shell Programming and Scripting

comment and Uncomment single task out of multiple task

I have a file contains TASK gsnmpproxy { CommandLine = $SMCHOME/bin/gsnmpProxy.exe } TASK gsnmpdbgui { CommandLine = $SMCHOME/bin/gsnmpdbgui.exe I would like to comment and than uncomment specific task eg TASK gsnmpproxy Pls suggest how to do in shell script (9 Replies)
Discussion started by: madhusmita
9 Replies

4. Shell Programming and Scripting

Pls Help me out ... I want to check process status at regular intervals of time

I want to check process status at regular interval of time ... so i ha wirtten this BUT its not working when i placed this peace of code in .sh .. please help me out #!/bin/sh w = ps -ef|grep processname | wc - l echo $w if ; then Banner "Proceesname Problem" else Banner " Running... (5 Replies)
Discussion started by: srinivasvandana
5 Replies

5. Shell Programming and Scripting

Parse an XML task list to create each task.xml file

I have an task definition listing xml file that contains a list of tasks such as <TASKLIST <TASK definition="Completion date" id="Taskname1" Some other <CODE name="Code12" <Parameter pname="Dog" input="5.6" units="feet" etc /Parameter> <Parameter... (3 Replies)
Discussion started by: MissI
3 Replies

6. Shell Programming and Scripting

Divide numbers into intervals

divide input values into specified number (-100 or -200) according to the key (a1 or a2 ....) For ex: if we give -100 in the command line it would create 100 number intervals (1-100, 100-200, 200-300) untill it covers the value 300 in a1. Note: It should work the same even with huge numbers... (3 Replies)
Discussion started by: ruby_sgp
3 Replies

7. Shell Programming and Scripting

Remove a block of Text at regular intervals

Hello all, I have a text files that consists of blocks of text. Each block of text represents a set of Cartesian coordinates for a molecule. Each block of text starts with a line that has a only a number, which is equal to the total number of atoms in the molecule. After this number is a line... (15 Replies)
Discussion started by: marcozd
15 Replies

8. Programming

Selecting files in regular intervals from a folder

Hi, I need your expertise in selecting files from a folder. I have files named with convention: filename.i.j where j is an interger from 1 to 16, for each i which is an integer from 1 to 2000. I would like to select the files with i in regular interval of 50 like filename.1.j,... (2 Replies)
Discussion started by: rpd25
2 Replies

9. UNIX for Dummies Questions & Answers

Bulk load testing in regular intervals

I need to write a script which can send files via sftp communication continously for half an hour or any given duration of time. I have already written a batch file to send multiple file via SFTP. but I need to know how can we set a duration of half an hour through shell script. Can we use sleep... (2 Replies)
Discussion started by: talk1234
2 Replies

10. UNIX for Dummies Questions & Answers

Building intervals

Hi all, I hope you can help me with the following question: I have multiple tables like this: Chr Start End Zygosity Gene chr1 153233510 153233510 het LOR chr1 153233615 153233615 hom LOR chr1 153233701 153233701 hom LOR chr1 ... (5 Replies)
Discussion started by: lsantome
5 Replies
PIDSTAT(1)                                                      Linux User's Manual                                                     PIDSTAT(1)

NAME
pidstat - Report statistics for Linux tasks. SYNOPSIS
pidstat [ -C comm ] [ -d ] [ -h ] [ -I ] [ -l ] [ -p { pid [,...] | SELF | ALL } ] [ -r ] [ -s ] [ -t ] [ -T { TASK | CHILD | ALL } ] [ -u ] [ -V ] [ -w ] [ interval [ count ] ] DESCRIPTION
The pidstat command is used for monitoring individual tasks currently being managed by the Linux kernel. It writes to standard output activities for every task selected with option -p or for every task managed by the Linux kernel if option -p ALL has been used. Not select- ing any tasks is equivalent to specifying -p ALL but only active tasks (tasks with non-zero statistics values) will appear in the report. The pidstat command can also be used for monitoring the child processes of selected tasks. Read about option -T below. The interval parameter specifies the amount of time in seconds between each report. A value of 0 (or no parameters at all) indicates that tasks statistics are to be reported for the time since system startup (boot). The count parameter can be specified in conjunction with the interval parameter if this one is not set to zero. The value of count determines the number of reports generated at interval seconds apart. If the interval parameter is specified without the count parameter, the pidstat command generates reports continuously. You can select information about specific task activities using flags. Not specifying any flags selects only CPU activity. OPTIONS
-C comm Display only tasks whose command name includes the string comm. This string can be a regular expression. -d Report I/O statistics (kernels 2.6.20 and later only). The following values are displayed: PID The identification number of the task being monitored. kB_rd/s Number of kilobytes the task has caused to be read from disk per second. kB_wr/s Number of kilobytes the task has caused, or shall cause to be written to disk per second. kB_ccwr/s Number of kilobytes whose writing to disk has been cancelled by the task. This may occur when the task truncates some dirty pagecache. In this case, some IO which another task has been accounted for will not be happening. Command The command name of the task. -h Display all activities horizontally on a single line. This is intended to make it easier to be parsed by other programs. -I In an SMP environment, indicate that tasks CPU usage (as displayed by option -u ) should be divided by the total number of proces- sors. -l Display the process command name and all its arguments. -p { pid [,...] | SELF | ALL } Select tasks (processes) for which statistics are to be reported. pid is the process identification number. The SELF keyword indi- cates that statistics are to be reported for the pidstat process itself, whereas the ALL keyword indicates that statistics are to be reported for all the tasks managed by the system. -r Report page faults and memory utilization. When reporting statistics for individual tasks, the following values are displayed: PID The identification number of the task being monitored. minflt/s Total number of minor faults the task has made per second, those which have not required loading a memory page from disk. majflt/s Total number of major faults the task has made per second, those which have required loading a memory page from disk. VSZ Virtual Size: The virtual memory usage of entire task in kilobytes. RSS Resident Set Size: The non-swapped physical memory used by the task in kilobytes. %MEM The tasks's currently used share of available physical memory. Command The command name of the task. When reporting global statistics for tasks and all their children, the following values are displayed: PID The identification number of the task which is being monitored together with its children. minflt-nr Total number of minor faults made by the task and all its children, and collected during the interval of time. majflt-nr Total number of major faults made by the task and all its children, and collected during the interval of time. Command The command name of the task which is being monitored together with its children. -s Report stack utilization. The following values are displayed: PID The identification number of the task being monitored. StkSize The amount of memory in kilobytes reserved for the task as stack, but not necessarily used. StkRef The amount of memory in kilobytes used as stack, referenced by the task. Command The command name of the task. -t Also display statistics for threads associated with selected tasks. This option adds the following values to the reports: TGID The identification number of the thread group leader. TID The identification number of the thread being monitored. -T { TASK | CHILD | ALL } This option specifies what has to be monitored by the pidstat command. The TASK keyword indicates that statistics are to be reported for individual tasks (this is the default option) whereas the CHILD keyword indicates that statistics are to be globally reported for the selected tasks and all their children. The ALL keyword indicates that statistics are to be reported for individual tasks and globally for the selected tasks and their children. Note: Global statistics for tasks and all their children are not available for all options of pidstat. Also these statistics are not necessarily relevant to current time interval: The statistics of a child process are collected only when it finishes or it is killed. -u Report CPU utilization. When reporting statistics for individual tasks, the following values are displayed: PID The identification number of the task being monitored. %usr Percentage of CPU used by the task while executing at the user level (application), with or without nice priority. Note that this field does NOT include time spent running a virtual processor. %system Percentage of CPU used by the task while executing at the system level (kernel). %guest Percentage of CPU spent by the task in virtual machine (running a virtual processor). %CPU Total percentage of CPU time used by the task. In an SMP environment, the task's CPU usage will be divided by the total num- ber of CPU's if option -I has been entered on the command line. CPU Processor number to which the task is attached. Command The command name of the task. When reporting global statistics for tasks and all their children, the following values are displayed: PID The identification number of the task which is being monitored together with its children. usr-ms Total number of milliseconds spent by the task and all its children while executing at the user level (application), with or without nice priority, and collected during the interval of time. Note that this field does NOT include time spent running a virtual processor. system-ms Total number of milliseconds spent by the task and all its children while executing at the system level (kernel), and col- lected during the interval of time. guest-ms Total number of milliseconds spent by the task and all its children in virtual machine (running a virtual processor). Command The command name of the task which is being monitored together with its children. -V Print version number then exit. -w Report task switching activity (kernels 2.6.23 and later only). The following values are displayed: PID The identification number of the task being monitored. cswch/s Total number of voluntary context switches the task made per second. A voluntary context switch occurs when a task blocks because it requires a resource that is unavailable. nvcswch/s Total number of non voluntary context switches the task made per second. A involuntary context switch takes place when a task executes for the duration of its time slice and then is forced to relinquish the processor. Command The command name of the task. ENVIRONMENT
The pidstat command takes into account the following environment variable: S_TIME_FORMAT If this variable exists and its value is ISO then the current locale will be ignored when printing the date in the report header. The pidstat command will use the ISO 8601 format (YYYY-MM-DD) instead. EXAMPLES
pidstat 2 5 Display five reports of CPU statistics for every active task in the system at two second intervals. pidstat -r -p 1643 2 5 Display five reports of page faults and memory statistics for PID 1643 at two second intervals. pidstat -C "fox|bird" -r -p ALL Display global page faults and memory statistics for all the processes whose command name includes the string "fox" or "bird". pidstat -T CHILD -r 2 5 Display five reports of page faults statistics at two second intervals for the child processes of all tasks in the system. Only child processes with non-zero statistics values are displayed. BUGS
/proc filesystem must be mounted for the pidstat command to work. FILES
/proc contains various files with system statistics. AUTHOR
Sebastien Godard (sysstat <at> orange.fr) SEE ALSO
sar(1), top(1), ps(1), mpstat(1), iostat(1), vmstat(8) http://pagesperso-orange.fr/sebastien.godard/ Linux AUGUST 2011 PIDSTAT(1)
All times are GMT -4. The time now is 01:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy