There are 2 ways to check this problem :
1. One is to go to the System Monitor and click on the Processes tab. Sort by %CPU Used and the offending process should pop to the top.
2. The other way is to executed a terminal and type “top” w/o the quotes. Top is a great little application that lists the top users of CPU time, plus gives a bunch of great info at the top of the terminal screen like total uptime, CPU info, process statistic
There are 3 possible solution to solve this problem :
1. Edit /etc/cron.weekly/apt-xapian-index
nice $IONICE -c3 $CMD --quiet
Cron is a utility for scheduling tasks to run at certain times. System tasks run weekly are, unsurprisingly, stored in the /etc/cron.weekly directory. You can also set up personal tasks to run pretty much whenever you want. For that, have a look at man crontab.
Looking at the internals of the code we're using here, the first line, the "crunchbang" line (#!), tells the system what executable to use to run the contents -- in this case, /bin/sh, or your basic shell.
The next two lines establish two shorthand variables. Variables in shell scripts are generally defined in ALL CAPS for easy readability. This is more of a best practice than any hard-and-fast requirement. When referenced later in the script, the variable names are prefixed with a $. Here, CMD is simply shorthand for the path to the update-apt-xapian-index binary, and IONICE is shorthand for the path to the ionice utility for getting or setting a process's I/O scheduling class and priority.
In the if statements, the -x checks to see if the next argument exists, so if [ -x $CMD ] will check to see if /usr/sbin/update-apt-xapian-index exists in the filesystem.
nice -n is basically how you assign a priority to a process. An important caveat, however, is that nice is just that -- a high nice value (up to a maximum of -n 19) means the process is nice and gets out of the way, and a low nice value (down to a minimum of -n -20) means the process is *not* nice and barges to the front of the line to be the first to use system resources. Niceness defaults to 10 if not otherwise specified, and apparently the default update-apt-xapian-index setup does not specify any value.
ionice is new in this fix. It works along similar lines, affecting a process's input/output niceness, only using the flag -c for "class". The ionice man page describes -c:
The scheduling class. 0 for none, 1 for real time, 2 for best-effort, 3 for idle.
Finally, we have the two options passed to update-apt-xapian-index itself, --update and --quiet. --quiet just tells it to not generate much text, only outputting for fatal errors, which makes sense for a background process. --update is new here in this fix together with the nice value and the ionice prioritization, and is a real kicker: it tellsupdate-apt-xapian-index to only update those items in the index that have actually changed. This seems like a no-brainer, since the index includes *every* package installed in the system, but unfortunately the default update-apt-xapian-index setup in a fresh install of Jaunty, Karmic, or Lucid all leave this option out, meaning thatupdate-apt-xapian-index will rebuild the ENTIRE package index every time it runs. No wonder it eats up so much memory and CPU time! With --update, it should take much less resources and much less time.
sudo chmod 644 /etc/cron.weekly/apt-xapian-index
Note : Purging apt-xapian-index causes the quick search feature in Synaptic to become inoperative.