13

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?

19

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.

1

Go to 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.

See: Bash scripting Tutorial.

1
  • As I said I did it but it store some binary character within it.
    – Behzadsh
    Nov 10 '10 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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