Sponsored Content
Full Discussion: Top utility in bash for loop
Top Forums Shell Programming and Scripting Top utility in bash for loop Post 302738783 by Yoda on Sunday 2nd of December 2012 07:39:17 PM
Old 12-02-2012
You can do the following to achieve this:-
  • Run top command
top
  • Press O and then p to select sort by SWAP usage.
  • Press W to save this settings it to .toprc file
  • Now you can put below command in loop to get the list of processes sorted by SWAP usage:-
top -n 1

I hope this helps.
This User Gave Thanks to Yoda For This Post:
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unload utility with loop method

Hi, I just wonder why the unload tools from INFORMIX doesn't unload all required file to every output of mOutFile at the accumulative way OR my script has an error ? In fact it just unload to one single record at the latest. for mFile in x??? do echo "Now working with file "$mFile"... (1 Reply)
Discussion started by: cedrichiu
1 Replies

2. Programming

top command line utility

I'm writing a monitoring application. I'd like to periodically get the information provided by the 'top' command line utility from within my code and write the output of 'top' to a file. Wondering if anyone has already done something like this. Doing system("top > someFile"); does not create... (6 Replies)
Discussion started by: antoniomorandi
6 Replies

3. Shell Programming and Scripting

Need help on bash "find" utility

Hi all, I need to write a script "hunt" that is similar to "find" without using "find" in there. Also have to print out how many subdirectories it's got. like if I type: $hunt unixit will show: 2 /home/var/unix something like that. I have no idea how to do the file search without using find... (2 Replies)
Discussion started by: sonyd8
2 Replies

4. Shell Programming and Scripting

bash and ksh: variable lost in loop in bash?

Hi, I use AIX (ksh) and Linux (bash) servers. I'm trying to do scripts to will run in both ksh and bash, and most of the time it works. But this time I don't get it in bash (I'm more familar in ksh). The goal of my script if to read a "config file" (like "ini" file), and make various report.... (2 Replies)
Discussion started by: estienne
2 Replies

5. UNIX for Dummies Questions & Answers

Top level TCSH while Loop doen't work

Hey guys... I'm learning some shell scripting on OS X using the tcsh shell. For some reason... my while loop isn't executing right (or more likely I am doing something wrong.) Something as simple as this doesn't work: #!/bin/tcsh set g = 0 while ($g <10) echo "this" $g @ g =... (2 Replies)
Discussion started by: sprynmr
2 Replies

6. Shell Programming and Scripting

Using variables created sequentially in a loop while still inside of the loop [bash]

I'm trying to understand if it's possible to create a set of variables that are numbered based on another variable (using eval) in a loop, and then call on it before the loop ends. As an example I've written a script called question (The fist command is to show what is the contents of the... (2 Replies)
Discussion started by: DeCoTwc
2 Replies

7. Shell Programming and Scripting

BASH loop inside a loop question

Hi all Sorry for the basic question, but i am writing a shell script to get around a slightly flaky binary that ships with one of our servers. This particular utility randomly generates the correct information and could work first time or may work on the 12th or 100th attempt etc !.... (4 Replies)
Discussion started by: rethink
4 Replies

8. UNIX for Beginners Questions & Answers

Bash script - Remove the 3 top level of a full path filename

Hello. Source file are in : /a/b/c/d/e/f/g/some_file Destination is : /d/e where sub-directories "f" and "g" may missing or not. After copying I want /a/b/c/d/e/f/g/file1 in /d/e/f/g/file1 On source /a is top-level directory On destination /d is top-level directory I would like... (2 Replies)
Discussion started by: jcdole
2 Replies
RESCAN-SCSI-BUS.SH(1)						   User Commands					     RESCAN-SCSI-BUS.SH(1)

NAME
rescan-scsi-bus.sh - script for adding and removing SCSI devices without rebooting SYNOPSIS
rescan-scsi-bus.sh [options] [host [host ...]] OPTIONS
-a, --alltargets scan all targets, not just currently existing [default: disabled] -d enable debug [default: 0] -l activates scanning for LUNs 0--7 [default: 0] -L NUM activates scanning for LUNs 0--NUM [default: 0] -w, --wide scan for target device IDs 0--15 [default: 0--7] -c enables scanning of channels 0 1 [default: 0 / all detected ones] -r, --remove enables removing of devices [default: disabled] -f, --flush flush failed multipath devices [default: disabled] -i, --issue-lip issue a FibreChannel LIP reset [default: disabled] -u, --update look for existing disks that have been remapped -s, --resize look for resized disks and reload associated multipath devices, if applicable --forcerescan rescan existing devices --forceremove remove and readd every device (DANGEROUS) --nooptscan don't stop looking for LUNs is 0 is not found --color use coloured prefixes OLD/NEW/DEL --hosts=LIST scan only host(s) in LIST --channels=LIST scan only channel(s) in LIST --ids=LIST scan only target ID(s) in LIST --luns=LIST scan only lun(s) in LIST --sync, --nosync issue a sync / no sync [default: sync if remove] --attachpq3 tell kernel to attach sg to LUN 0 that reports PQ=3 --reportlun2 tell kernel to try REPORT_LUN even on SCSI2 devices --largelun tell kernel to support LUNs > 7 even on SCSI2 devs --sparselun tell kernel to support sparse LUN numbering Host numbers may thus be specified either directly on cmd line (deprecated) or or with the --hosts=LIST parameter (recommended). LIST: A[-B][,C[-D]]... is a comma separated list of single values and ranges (No spaces allowed.) SEE ALSO
rescan-scsi-bus.sh Homepage: http://www.garloff.de/kurt/linux/#rescan-scsi sg3_utils Homepage: http://sg.danny.cz/sg rescan-scsi-bus.sh 1.57 leden 2014 RESCAN-SCSI-BUS.SH(1)
All times are GMT -4. The time now is 01:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy