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.

How can I log the installation of packages in Ubuntu? I want to send a message to log every time after a package is installed, like, "Package Installed" with the name of package & it should do that after uninstalling too. Is this possible? I am logging all this in a file called "Local3.log".

share|improve this question
add comment

2 Answers 2

It appears that apt logs this data here:

/var/log/apt/term.log

This blog had this and more info on package logging:

http://tech.zhenhua.info/2010/11/package-installation-log-on-ubuntu-dpkg.html

share|improve this answer
add comment

Yes you can do it. (You can use /var/log/apt/history.log* files or the method below)

First you have to create a shell script named apt-get(as shown below)

Then you have to add it to your PATH variable. You can do it by adding it to the /etc/profile for example if your script is located in /home/ankur/ you have to add a line to /etc/profile like the line below. export PATH=/home/ankur/:$PATH

Now whenever you execute apt-get our script executes first

(This might not be the perfect script) apt-get

 #!/bin/bash
if [ $1 = "install" ] || [ $1 = "remove" ] || [ $1 = "purge" ];
then
    sudo /usr/bin/apt-get $*
    echo $* >> /home/ankur/Local3.log
else
    /usr/bin/apt-get $*
fi
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.