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??
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:
Another method could be to use the tee(1) program to log all of your output.