Solved

send top command output to  a text file ?

Posted on 2013-06-10
2
376 Views
Last Modified: 2013-06-10
Hello, I am using an Ubuntu 12.04 Linux system and am trying to capture the output of the top command using the following command:

 sudo top -n 1 -b > top-output.txt

when I run this command I get the following error, can someone let me know what I need to do to avoid this error and be able to capture the output as a text file?

-bash: top-output.txt: Permission denied
 

Thank you,
A
0
Comment
Question by:aej1973
2 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 250 total points
ID: 39233948
sudo will run top with root privs, but any file redirection will occur as the userid invoking the command.

Unless sudo has suid disabled, then there's no need to use sudo.

Just redirect the output to a directory you have write permission for, eg:

top -n 1 -b >/tmp/top-output.txt
0
 

Author Comment

by:aej1973
ID: 39234005
Thank you, it works.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now