How can i send a message to a log file (not the apt log) after the installation of a package. I simple want to log which package (package name) was installed. ie. "links installed successfully"
/var/log/dpkg.log should contain the information you want:
Log status change updates and actions to filename, instead of the default /var/log/dpkg.log.
If this option is given multiple times, the last filename is used.
Log messages are of the form:
YYYY-MM-DD HH:MM:SS startup type commandfor each dpkg invocation where type is archives (with a command of unpack or install) or packages (with a command of configure, triggers-only, remove or purge);
YYYY-MM-DD HH:MM:SS status state pkg installed-versionfor status change updates;
YYYY-MM-DD HH:MM:SS action pkg installed-version available-versionfor actions where action is one of install, upgrade, configure, trigproc, disappear, remove or purge;
YYYY-MM-DD HH:MM:SS conffile filename decisionfor conffile changes where decision is either install or keep.
e.g. I installed
ksh this morning to investigate a difference between
# grep ksh /var/log/dpkg.log 2015-11-18 09:39:52 install ksh:amd64 <none> 93u+20120801-2 2015-11-18 09:39:52 status half-installed ksh:amd64 93u+20120801-2 2015-11-18 09:39:52 status half-installed ksh:amd64 93u+20120801-2 2015-11-18 09:39:52 status unpacked ksh:amd64 93u+20120801-2 2015-11-18 09:39:52 status unpacked ksh:amd64 93u+20120801-2 2015-11-18 09:39:57 configure ksh:amd64 93u+20120801-2 <none> 2015-11-18 09:39:57 status unpacked ksh:amd64 93u+20120801-2 2015-11-18 09:39:57 status unpacked ksh:amd64 93u+20120801-2 2015-11-18 09:39:57 status half-configured ksh:amd64 93u+20120801-2 2015-11-18 09:39:57 status installed ksh:amd64 93u+20120801-2
If you just want to know when packages have been installed or upgraded, try something like this:
# zgrep -E '(install|upgrade) bash[: ]' /var/log/dpkg.log* /var/log/dpkg.log.12.gz:2014-11-25 12:19:59 upgrade bash:amd64 4.3-11 4.3-11+b1 /var/log/dpkg.log.2.gz:2015-09-12 18:52:44 upgrade bash:amd64 4.3-13 4.3-14 /var/log/dpkg.log.4.gz:2015-07-29 10:27:33 upgrade bash:amd64 4.3-12 4.3-13 /var/log/dpkg.log.9.gz:2015-02-09 11:54:56 upgrade bash:amd64 4.3-11+b1 4.3-12
[: ] in the regex is to exclude other packages such as
bash-doc etc from the listing.
logger can be used for this, like
logger package installed successfully
You can use:
sudo apt-get install somepackage && echo somepackage installed successfully >> mylogfile.log
It's a bit silly, but it answers the exact question you asked. It only puts the message into mylogfile.log if the install succeeded.
(If that doesn't help, add more detail to your question and I will try to help.)