Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
1  
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
add comment

1 Answer

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
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

cheers

sc.

share|improve this answer
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.