Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have written a script for installing packages on Linux(Ubuntu). So I want to create a log file for installation of packages for troubleshooting if any problem occur during installation.So please suggest me a way to how to go for it??

share|improve this question
It's not really clear what kind of problem you are trying to solve. When you install a package in a dpkg-based system, it will already keep a log of what was done, with the result of each installation, uninstallation, or partial operation: /var/log/dpkg.log. – rbrito Feb 27 '13 at 6:30

If you want to manually review the session for errors after (and you have not indicated whether you want "catching" of errors, or just an overall session transcript, so i'll assume the latter), then you could use the script(1) program:

script my_log_file.log
foo@pc:~$ script my_log_file.log
Script started, file is my_log_file.log
foo@pc:~$ echo "do stuff here"
do stuff here
foo@pc:~$ exit
Script done, file is my_log_file.log

Another method could be to use the tee(1) program to log all of your output.

foo@pc:~$ ./install_pkg.sh | tee -a my_log_file.log



share|improve this answer

Your Answer


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.