Top command in batch mode
Run the following command to begin top in batch mode, logging to a file called TOP_LOG:
top icbd .1 | egrep -v “top|Tasks|Cpu|Mem|Swap|PID|top icbd|^$|tee -a” | tee -a top_log
- Code breakdown:
top icbd .1 Run the top command with the idle processes being shown, full command line paths being shown, running inbatch mode, and with the delay set to .1seconds so that it quickly refreshes. egrep -v “top|Tasks|Cpu|Mem|Swap|PID|top icbd|^$|tee -a” Use the egrepcommand with the -vflag to not show any lines that include top,Tasks, Cpu, Mem,Swap, PID, top icbd,^$ which is any blank line, or tee -a. This way we only see lines from top that have process information. tee -a TOP_LOG Finally use the teecommand with the -append flag to simultaneously write the data from the topcommand out to a file called TOP_LOG. - After you’ve let this run for some time to gather data, you can go ahead and hit Ctrl-C to stop thetop command from gathering more data.
- cat TOP_LOG| sort -k9| tail -20| sort -k2
- You should end up with something that looks like this:
- —————————-
14238 askhacke 17 0 201m 42m 21m R 97.4 0.4 0:00.20 /usr/bin/php /home/askhacke/public_html/index.php
14238 askhacke 17 0 217m 72m 34m R 97.3 0.6 0:00.42 /usr/bin/php /home/askhacke/public_html/index.php
14186 askhacke 18 0 217m 72m 34m R 99.1 0.6 0:00.71 /usr/bin/php /home/askhacke/public_html/index.php
14186 askhacke 18 0 217m 72m 34m R 99.2 0.6 0:00.92 /usr/bin/php /home/askhacke/public_html/index.php
14131 gotomyin 17 0 193m 27m 14m R 99.1 0.2 0:00.11 /usr/bin/php /home/gotomyin/public_html/showthread.php
20510 gotomyin 17 0 197m 34m 16m R 97.4 0.3 0:00.17 /usr/bin/php /home/gotomyin/public_html/newthread.php
14064 integrat 17 0 196m 35m 18m R 98.1 0.3 0:00.14 /usr/bin/php /home/integrat/public_html/wp-admin/admin-ajax.php
14262 jollence 17 0 205m 51m 25m R 99.0 0.4 0:00.25 /usr/bin/php /home/jollence/public_html/wp-cron.php
—————————- - Once you are done reviewing the data in our TOP_LOGfile you can run the following command to remove this file:rm -rf ./TOP_LOG
- Thanks to inmotionhosting.com Jacob Nicholson 🙂
-
Recent
- Top command in batch mode
- Malware on Linux Server (Maldet)
- The script to kill DoS/DDoS botnet on the OpenVZ hardware node
- How to set limit to remove the Frozen Maiils Automatically ?
- Script to catch malicious perl scipts uploaded to /tmp
- Exploit Removal Guide
- Frozen messages with Exim
- DDOs Commands
- SERVER LOAD TWEAKS…APACHE/MYSQL/SMTP-POP3/EXIM/IMAP
- Change Theme Without Login To WordPress Admin Area
- How do I find out zombie process?
- Command to check mod_pagespeed
-
Links
-
Archives
- March 2013 (1)
- February 2013 (8)
- January 2013 (2)
- December 2012 (7)
- November 2012 (24)
- October 2012 (44)
- September 2012 (10)
- August 2012 (13)
- July 2012 (8)
- June 2012 (5)
- May 2012 (44)
- April 2012 (8)
-
Categories
- Apache
- Cloud Linux
- Computers & Electronic
- Control Panel
- CPanel / WHM
- Education
- Enertainment
- fashion
- File Sharing
- Firefox
- Gadgets
- Games
- General
- Graphics & Design
- Health
- Hot Shot
- Humor
- Icons
- Installation
- Internet
- Iphone
- Laptops
- Linux
- Mega Projects
- Microsoft
- Mobile News
- Mobile Phones
- MySql
- PHP
- Plesk
- Portable Softwares
- Reviews
- Security
- Social Media
- Software & Utilities
- SolusVM
- Sports Channels
- Technology
- Thoughts
- Tips & Tricks
- Uncategorized
- Wallpapers
- Web 2.0
- WHM Plugins
- Windows
- Wordpress
- YouTube
-
RSS
Entries RSS
Comments RSS