LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-31-2010, 05:31 AM   #1
josecolella
Member
 
Registered: Nov 2010
Location: Milan, Italy
Distribution: Linux Mint 13, Debian 6.0
Posts: 62

Rep: Reputation: 3
Question Script that names the process in the system that consumes the most memory


I am writing a script that tells me which process consumes the most memory in the system

this is what I have but I keep getting an error:

#! /bin/bash
# Autor: Jose miguel Colella
# Descripcion: Que proceso consume mas memoria



ps -e -o %mem -o args | sort -k 1 | tail -n2 | head -n1 | cut -d -f 3

I keep getting this message: cut: delimiter mist be a single character
 
Old 12-31-2010, 05:40 AM   #2
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,064

Rep: Reputation: 894Reputation: 894Reputation: 894Reputation: 894Reputation: 894Reputation: 894Reputation: 894
Quote:
Originally Posted by josecolella View Post
I am writing a script that tells me which process consumes the most memory in the system

this is what I have but I keep getting an error:

#! /bin/bash
# Autor: Jose miguel Colella
# Descripcion: Que proceso consume mas memoria



ps -e -o %mem -o args | sort -k 1 | tail -n2 | head -n1 | cut -d -f 3

I keep getting this message: cut: delimiter mist be a single character
I'm not quite sure what you want as the output; did you want something more like this

Code:
ps -e -o %mem -o args | sort -k 1 | tail -n2 | head -n1 | cut -d ' ' -f 2
or something else?
 
Old 12-31-2010, 05:48 AM   #3
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,300

Rep: Reputation: 102Reputation: 102
It runs fine on my system

Code:
# ps -e -o %mem -o args | sort -k 1 | tail -n2 | head -n1 | cut -d "" -f 3
 0.9 /usr/bin/python -tt /usr/sbin/yum-updatesd
As per your command your double quotes ("") seem to be a little tilted. Try straight quotes, it must work for you.
 
Old 12-31-2010, 08:37 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,565

Rep: Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901
Maybe this can help lessen the extra tail/head options:
Code:
ps h -e -o %mem -o args | sort -k 1 | tail -n1 | cut -d "" -f 3
 
Old 01-03-2011, 08:23 AM   #5
josecolella
Member
 
Registered: Nov 2010
Location: Milan, Italy
Distribution: Linux Mint 13, Debian 6.0
Posts: 62

Original Poster
Rep: Reputation: 3
grail,
Thanks for your help, your command was most useful, it not only told me how much memory the process consumed but it told me the process
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux shell script .sh file consumes high memory dsksiva Linux - General 3 09-09-2010 08:12 AM
Samba process consumes hard disk space bobmac010 Linux - Server 2 04-17-2009 01:23 PM
gil = TCP/IP process consumes a lot of CPU pete83 AIX 1 05-09-2008 03:57 AM
Help: rhel4->rhel5==>Matlab consumes more memory pronuncer Linux - Kernel 4 01-18-2008 06:40 PM
How much Linux consumes memory? Eits0 Linux - General 5 09-02-2002 05:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration