High CPU/RAM Usage by "update-apt-xapi"
So I've been getting warnings from my host lately regarding high CPU and memory use on my VPSs. From what I could tell, the offending process was update-apt-xapi
- it would be consuming all the CPU time for hours and use quite a bit of RAM. Some research pointed to the update-apt-xapian-index
script in /etc/cron.weekly
. It's suppose to be responsible for maintaining an index of packages to speed up search on Synaptic.
Looks something like this:
#!/bin/sh
CMD=/usr/sbin/update-apt-xapian-index
IONICE=/usr/bin/ionice
# Rebuild the index
if [ -x $CMD ]
then
if [ -x $IONICE ]
then
nice $IONICE -c3 $CMD --quiet
else
nice $CMD --quiet
fi
fi
The -n 19
option may already be in place, so in that case simply replace the following:
nice $IONICE -c3 $CMD --quiet
nice $CMD --quiet
with
nice -n 19 $IONICE -c 3 $CMD --update --quiet
nice -n 19 $CMD --update --quiet
First -n 19
flag gives it the least favorable scheduling priority while --update
prevents the index from being rebuilt every time. This should reduce CPU use when the script is being run.