- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Why doesn't top command work in my script?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-09-2008 09:01 PM
тАО01-09-2008 09:01 PM
Why doesn't top command work in my script?
I have a script as bellow
--
GetDate=`date +"%Y%m%d"`
LOG_NM=/home/hoanglh/report$GetDate
who -q|grep users>>$LOG_NM
sar -d 5 5 >>$LOG_NM
/usr/bin/top -h -d 1 >>$LOG_NM
Exit
---
All command above /usr/bin/top ran OK.
except /usr/bin/top command did not work?? i do not know why??? Just suspect of exit command
Have you ever experience with??
- Tags:
- top
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-09-2008 09:20 PM
тАО01-09-2008 09:20 PM
Re: Why doesn't top command work in my script?
export UNIX95=1;/usr/bin/top -h -n5 -d1 -f >>$LOG_NM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-09-2008 09:41 PM - edited тАО09-17-2011 04:36 PM
тАО01-09-2008 09:41 PM - edited тАО09-17-2011 04:36 PM
Re: Why doesn't top command work in my script?
>ahsan: export UNIX95=1;/usr/bin/top -h -n5 -d1 -f >>$LOG_NM
Why would you use UNIX95? That's for ps(1).
Also, you don't want to export it:
$ UNIX95=EXTENDED_PS ps -Hfu $LOGNAME
- Tags:
- UNIX95
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-09-2008 09:49 PM
тАО01-09-2008 09:49 PM
Re: Why doesn't top command work in my script?
anyway nguyen you can just ignore the export .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-10-2008 01:17 AM
тАО01-10-2008 01:17 AM
Re: Why doesn't top command work in my script?
But apart from the useless use of UNIX95 in top context,
setting it as suggested (i.e. along with the false trailing semicolon) is utterly wrong, insofar as a set environment variable will change the behavior of all XPG4 aware commands for the pending shell with possibly escaping the notice of the shell's user.
So the recommended usage of this environment variable is in fact as Dennis has demonstrated so that it only effects the command immediately issued.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-10-2008 05:12 AM
тАО01-10-2008 05:12 AM
Re: Why doesn't top command work in my script?
To add to your answer. Using 'top' without the '-f filename' switch and argument (as you did) tells 'top' to add terminal-formatting codes to its output stream. This renders the redirected output in your logfile rather useless.
You want:
# top -h -d 1 -f ${LOG_NM}
Notice that NO redirection is used. 'top' will append to the file used as the argument of '-f'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-11-2008 01:49 AM
тАО01-11-2008 01:49 AM
Re: Why doesn't top command work in my script?
I do not want to export UNIX95 because it effects to my environment.
I changed my script as
UNIX95=1;/usr/bin/top -h -d 1 >>$LOG_NM
but it still did not works.
Hi ahsan, Ralph do you have any ideas???
I will changes my script as
/usr/bin/top -h -d -f $LOG_NM
I will rely the result soon
thank for your help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-11-2008 04:09 AM
тАО01-11-2008 04:09 AM
Re: Why doesn't top command work in my script?
> but it still did not works.
Remove UNIX95 completely from your script. It has no meaning here.
> I will changes my script as
> /usr/bin/top -h -d -f $LOG_NM
This will work just fine. top was not originally designed as a script program but instead manipulates your terminal window. So the -f option in top turns off this special handling.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-11-2008 04:37 AM
тАО01-11-2008 04:37 AM
Re: Why doesn't top command work in my script?
Read again my post, above.
> I will changes my script as
/usr/bin/top -h -d -f $LOG_NM
That will not work, you need:
I will changes my script as
/usr/bin/top -h -d1 -f $LOG_NM
...or a least a non-zero argument following the '-d' switch.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-18-2008 12:23 AM
тАО01-18-2008 12:23 AM
Re: Why doesn't top command work in my script?
I change my script as:
===
GetDate=`date +"%Y%m%d"`
LOG_NM=/home/hoanglh/report$GetDate
who -q|grep users>>$LOG_NM
sar -d 5 5 >>$LOG_NM
/usr/bin/top -h ├в d1 -f $LOG_NM
==
But top command doesn't works.
Please help me to point out why
Point has been assigned to acknowledge your support