Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How to display only the first 5 running process using top in shell scripting? Post 302986163 by RudiC on Monday 21st of November 2016 06:12:37 AM
Old 11-21-2016
You need one single iteration of top. With -n1, top leaves cleanly after that. Without it, it is killed because its output pipe has disappeared. Or, grep keeps waiting for more input...
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How Can I Have Top Display The Top 20 Processes??

how can i do that in a script withough havin the script halt at the section where the top command is located. am writign a script that will send me the out put of unx commands if the load average of a machine goes beyond the recommended number. top -n 20 i want to save this output to a file... (1 Reply)
Discussion started by: TRUEST
1 Replies

2. UNIX for Advanced & Expert Users

Top running process

Hi, I have an oracle process running on top for a week now, but I couldnt see the same process with in oracle. how do I know what this process is? -GK P.S: when I say i didn't see within oracle, what I mean is I didn't see this process through oracle utility which shows all the oracle process (1 Reply)
Discussion started by: caprikar
1 Replies

3. UNIX for Dummies Questions & Answers

top ten utilities in shell scripting?

Let's get some feedback about the top ten ute's you guys use in writing your scripts - I mean yeah it depends on the job and what you're trying to accomplish, but there ARE those commands (sed, grep, awk, cut, etc.) that most will use time and again... ...so, what do you use? (3 Replies)
Discussion started by: diego
3 Replies

4. UNIX for Dummies Questions & Answers

Shell scripting adding text to top of file

Hi this is quite simple i am sure but without using awk or sed i need to add text to the top of a file this is what i have got so far #!bin/bash echo "Add text to top of file" read line echo $line >> file1 This adds the text to the bottom of the file can some1 please help cheers (7 Replies)
Discussion started by: meadhere
7 Replies

5. UNIX for Dummies Questions & Answers

perl scripting for checking if a process is running

Hi All, I am new to perl and have been trying to write a short script to check a process.Though i havent reached to the stage where i can match the output. I am trying to pass a variable x with value /opt/RGw/csbp-base/CSBP_BAT.01.00.05/csbp_BAT.01.00.05.jar and then pass another variable... (2 Replies)
Discussion started by: pistachio
2 Replies

6. Shell Programming and Scripting

Shell script to display top 5 process (per cpu consumption)

Hello, I have to create shell script being myself real novice in scripting... I was looking on the Internet for some script examples, but I don't have the basic understanding of the shell. I was trying to do something with “ps” command without success. For exemple total number of... (2 Replies)
Discussion started by: mr_awd
2 Replies

7. Shell Programming and Scripting

How to calculate months and display in shell scripting

I just want to know, how do we calculate the months in shell scripting. If i give the input as 20-01-2011, the output should be 20-02-2011, 20-03-2011 or 20-04-2011........ How do i get this ? Cheers. (6 Replies)
Discussion started by: sachin24
6 Replies

8. Shell Programming and Scripting

Display the First and Last name from a file using shell scripting

I am new to shell scripting and doing a similar thing @ work Stan:Smith:Detroit:MI Jim:Jones:Farmington Hills:MI Jack:Frost:Denver:CO Sue:Apple:New York:NY Cindy:Thompson:Battle Creek:MI John:Smith:Denver:CO George:Jones:New York:NY Need to create a shell script This script will display... (1 Reply)
Discussion started by: jakemathew
1 Replies

9. Shell Programming and Scripting

Need help in shell Scripting to display a output from a command

Please find my below requirement and see if you can help me on this. I am looking for a shell script which can provide me the below output. Manuall steps which i am doing now 1) First I source the File $ . ./WC_env.sh 2) Execute the command $ /app/oracle/product/mos/bin/mosotl -url... (2 Replies)
Discussion started by: sudheshpn@gmail
2 Replies

10. Shell Programming and Scripting

Display current directory for a running process for script

I'm trying to create a ksh script to do the following: 1) Ask the user what process they want to search for. 2) Have the script read the input as a variable and use it to search for the process. 3) Display the current time & date, the working directory of the process, and finally display the... (6 Replies)
Discussion started by: seekryts15
6 Replies
SYSTEMD-CGTOP(1)						   systemd-cgtop						  SYSTEMD-CGTOP(1)

NAME
systemd-cgtop - Show top control groups by their resource usage SYNOPSIS
systemd-cgtop [OPTIONS...] DESCRIPTION
systemd-cgtop shows the top control groups of the local Linux control group hierarchy, ordered by their CPU, memory, or disk I/O load. The display is refreshed in regular intervals (by default every 1s), similar in style to top(1). If systemd-cgtop is not connected to a tty, only one iteration is performed and no columns headers are printed. This mode is suitable for scripting. Resource usage is only accounted for control groups in the relevant hierarchy, i.e. CPU usage is only accounted for control groups in the "cpuacct" hierarchy, memory usage only for those in "memory" and disk I/O usage for those in "blkio". If resource monitoring for these resources is required, it is recommended to add the CPUAccounting=1, MemoryAccounting=1 and BlockIOAccounting=1 settings in the unit files in question (See systemd.resource-control(5) for details). To emphasize this: unless "CPUAccounting=1", "MemoryAccounting=1" and "BlockIOAccounting=1" are enabled for the services in question no resource accounting will be available for system services and the data shown by systemd-cgtop will be incomplete. OPTIONS
The following options are understood: -h, --help Prints a short help text and exits. --version Prints a version string and exits. -p Order by control group path name. -t Order by number of tasks in control group (i.e. threads and processes). -c Order by CPU load. -m Order by memory usage. -i Order by disk I/O load. -b, --batch Run in "batch" mode: do not accept input and run until the iteration limit set with --iterations is exhausted or until killed. This mode could be useful for sending output from systemd-cgtop to other programs or to a file. -n, --iterations= Perform only this many iterations. -d, --delay= Specify refresh delay in seconds (or if one of "ms", "us", "min" is specified as unit in this time unit). --depth= Maximum control group tree traversal depth. Specifies how deep systemd-cgtop shall traverse the control group hierarchies. If 0 is specified, only the root group is monitored. For 1, only the first level of control groups is monitored, and so on. Defaults to 3. KEYS
systemd-cgtop is an interactive tool and may be controlled via user input using the following keys: h Shows a short help text. SPACE Immediately refresh output. q Terminate the program. p, t, c, m, i Sort the control groups by path, number of tasks, CPU load, memory usage, or IO load, respectively. % Toggle between showing CPU time as time or percentage. +, - Increase or decrease refresh delay, respectively. EXIT STATUS
On success, 0 is returned, a non-zero failure code otherwise. SEE ALSO
systemd(1), systemctl(1), systemd-cgls(1), systemd.resource-control(5), top(1) systemd 208 SYSTEMD-CGTOP(1)
All times are GMT -4. The time now is 11:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy