Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to write batch or something, that will write output of top into a file on login.
I did top >> output-file but it contains some strange character!

can somebody give a simple tutorial about how to write batch file in linux?
thanks!

share|improve this question
add comment

2 Answers 2

up vote 8 down vote accepted

Try the following

top -b -n1 > filename.txt

The -b is for batch mode, which should prevent the strange characters. The -n1 tells it to only print one iteration.

share|improve this answer
add comment

Goto terminal and type:

user@ubuntu:~$ top > filename.txt

The output of top command will be now stored in a text file which is located in your Home Directory.

Learn Bash Scripting:

http://www.linuxconfig.org/Bash_scripting_Tutorial

share|improve this answer
    
As I said I did it but it store some binary character within it. –  Behzadsh Nov 10 '10 at 8:16
    
thanks for tutorial –  Behzadsh Nov 10 '10 at 8:54
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.