Friday, October 29, 2010

Keep track of Installed Packages in Debian

Since I usually do a 'aptitude update' followed by an 'aptitude safe-upgrade' and an 'aptitude full-upgrade' almost on a daily basis, I sometimes need to keep track of what was upgrade, installed or removed, because eventually those upgrades generate some problems or unexpected issues.


To keep track of it I generate a list of packages installed and orphans packages every day.

# m h  dom mon dow   command
00 02 * * * /usr/bin/updatedb
00 11 * * * /usr/bin/dpkg --get-selections > /root/debian-packages/`date +\%Y-\%m-\%d`-packages.list; SUFFIX=packages.list /root/debian-packages/deleteEquals.sh
01 11 * * * /usr/bin/deborphan > /root/debian-packages/`date +\%Y-\%m-\%d`-deborphan; SUFFIX=deborphan /root/debian-packages/deleteEquals.sh

Also, to don't waste space, I created a small script to remove the lists in case they don't have any changes, which is the "deleteEquals.sh" script.


The script just need the variable SUFFIX set so it knows which files should be checked, the whole script is below:

#!/bin/bash
SUFFIX=${SUFFIX:="packages.list"}
cd /root/debian-packages
for i in $(ls -1rt /root/debian-packages/*${SUFFIX}); do 
if [ -z $PREVIOUS ]; then 
PREVIOUS="$i";  
else 
diff -q $PREVIOUS $i > /dev/null 2>/dev/null; 
RESULT="$?"; 
if [ $RESULT -eq 0 ]; then
rm $PREVIOUS;
fi
PREVIOUS="$i"; 
fi;
 done

Thursday, October 7, 2010

Using ps to see the whole process command in Solaris

To see a long command line running in Linux you can use 'ps -efl', like this:



# ps -efl | grep chrome | tail -1 
1 S andre    12842  3822  2  80   0 - 344387 -     11:57 ?        00:06:56 /opt/google/chrome/chrome --type=renderer --lang=en-US --force-fieldtest=CacheSize/CacheSizeGroup_3/CacheThrottle/CacheThrottle_Off/ConnCountImpact/conn_count_6/ConnnectBackupJobs/ConnectBackupJobsEnabled/DnsImpact/default_enabled_prefetch/GlobalSdch/global_enable_sdch/IdleSktToImpact/idle_timeout_60/Prefetch/ContentPrefetchEnabled/ProxyConnectionImpact/proxy_connections_32/SpdyImpact/npn_with_spdy/ --enable-crash-reporter=1B284CE7461F92C501F326E117CE5DBE,Debian GNU/Linux testing (squeeze) --channel=3812.0x615ca00.296713068


But in Solaris it don't work the same way:


$ ps -efl | grep java | grep noaccess
 0 S noaccess  2258     1   0  40 20        ?  11434        ?   Aug 10 ?          64:33 /usr/java/bin/java -server -Xmx128m



But we can use the beautiful /usr/ucb/ps auxww


$ /usr/ucb/ps auxww | grep java | grep noaccess
noaccess  2258  0.0  0.39147284352 ?        S   Aug 10 64:32 /usr/java/bin/java -server -Xmx128m -XX:+UseParallelGC -XX:ParallelGCThreads=4


Hope this help some lost soul out there.