Why is Caja using 40% of my CPU?

Caja is being a vampire.

A search showed this has long been a problem.

I am doing some thinking.

  1. Should I remove Caja and continue to use Thunar ?

  2. Or can I keep it but find a way to reclaim the lost memory

  3. Or use "kill Caja" and only "fire it up when I need to use some feature that I need."

Probably because you are running into swap:
You have 2GB physical RAM but are using 2.5 GB according to htop.

Try to free up some memory.

EDIT: forget what I wrote here, I was really not awake when I wrote this, sorry.

2 Likes

This freed up some memory.

pkill caja

But should I need to do this ?

Usually not :slight_smile:

This only happens in impossible situations like deleting a folder when caja is busy copying files to it. Or opening a document while the called application is throwing a fit.

3 Likes

Before blaming Caja (or any other process), you might want to try running the following script to monitor how much CPU is being consumed, in general, or, if you prefer, for a single specific process.

The command line format would be of the form:

OS_Admin__MonitorUsage_CPU.sh    --mincpu 1.0

or the following form if you only want immediate reporting on one specific process:

OS_Admin__MonitorUsage_CPU.sh    --mincpu 1.0   --watch firefox

The below script is currently hard-coded for a 60 second interval between reporting scans.


Script [OS_Admin__MonitorUsage_CPU.sh]:

#!/bin/sh

doIgnore=0

while [ $# -gt 0 ]
do
	case $1 in
		"--mincpu" )
			minCpu=$2 ;
			shift ; shift ;
			;;
		"--watch" )
			command="$2" ;
			echo "command => ${command}" >&2
			shift ; shift ;
			;;
		"--ignore" )
			doIgnore=1
			shift
			;;
		--* )
			echo "Invalid option specified on command line.  Valid options:  [ --mincpu {real_number} ] [ --watch {process_basename} ]\n" ; exit 1 ;
			;;
	esac
done

if [ -z ${minCpu} ]
then
	minCpu=2.0
fi
echo "minCpu => ${minCpu}" >&2

while [ true ]
do
	now=$(date '+%F_%H:%M' )
	ps -eo pcpu,pid,user,args | sort -r -k1 |
		if [ ${doIgnore} -eq 1 ]
		then
			###	This logic to filter out cases reporting [kworker*] [jdb2*] and similar
			awk -v pat="^\\\[" '{
				if( $4 !~ pat ){
					print $0 ;
				} ;
			}'
		else
			cat
		fi |
		awk -v pmin="${minCpu}" -v pref="${now}" '{
			proc=$4 ;
			cnt=split( proc, cmd, "/" ) ;
			if( $1 >= pmin ){
				printf("%s| %s |%s\n", cmd[cnt], pref, $0 ) ;
			} ; 
		}' ;
	sleep 60 ;
done |
if [ -n "${command}" ]
then
	grep "${command}"
else
	cat
fi

Once started, that will run endlessly ... until you kill the process. The output will look like this:

minCpu => 1.0
firefox| 2025-09-12_15:55 | 2.4    3493 username /opt/firefox/firefox
Xorg| 2025-09-12_15:55 | 1.7    1374 root     /usr/lib/xorg/Xorg -dpms -core :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
mate-multiload-applet| 2025-09-12_15:55 | 1.1    2416 ericthe+ /usr/lib/mate-applets/mate-multiload-applet
firefox| 2025-09-12_15:56 | 2.4    3493 username /opt/firefox/firefox
Xorg| 2025-09-12_15:56 | 1.7    1374 root     /usr/lib/xorg/Xorg -dpms -core :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
mate-multiload-applet| 2025-09-12_15:56 | 1.1    2416 ericthe+ /usr/lib/mate-applets/mate-multiload-applet
firefox| 2025-09-12_15:57 | 2.4    3493 username /opt/firefox/firefox
Xorg| 2025-09-12_15:57 | 1.7    1374 root     /usr/lib/xorg/Xorg -dpms -core :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
mate-multiload-applet| 2025-09-12_15:57 | 1.1    2416 ericthe+ /usr/lib/mate-applets/mate-multiload-applet
firefox| 2025-09-12_15:58 | 2.3    3493 username /opt/firefox/firefox
Xorg| 2025-09-12_15:58 | 1.7    1374 root     /usr/lib/xorg/Xorg -dpms -core :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
mate-multiload-applet| 2025-09-12_15:58 | 1.1    2416 ericthe+ /usr/lib/mate-applets/mate-multiload-applet
firefox| 2025-09-12_15:59 | 2.4    3493 username /opt/firefox/firefox
Xorg| 2025-09-12_15:59 | 1.7    1374 root     /usr/lib/xorg/Xorg -dpms -core :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
mate-multiload-applet| 2025-09-12_15:59 | 1.1    2416 ericthe+ /usr/lib/mate-applets/mate-multiload-applet
firefox| 2025-09-12_16:00 | 2.4    3493 username /opt/firefox/firefox
Xorg| 2025-09-12_16:00 | 1.7    1374 root     /usr/lib/xorg/Xorg -dpms -core :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
mate-multiload-applet| 2025-09-12_16:00 | 1.1    2416 username /usr/lib/mate-applets/mate-multiload-applet
firefox| 2025-09-12_16:01 | 2.5    3493 username /opt/firefox/firefox
Xorg| 2025-09-12_16:01 | 1.7    1374 root     /usr/lib/xorg/Xorg -dpms -core :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
mate-multiload-applet| 2025-09-12_16:01 | 1.1    2416 username /usr/lib/mate-applets/mate-multiload-applet

The output format is geared to being able to filter, after the fact, for a particular command. Then, when that is needed, you can strip off the first column and get a record of usage reported with timestamp every minute. :slight_smile:


If you saved that output (without --watch) to a "logfile", you could then extract just the values for any one of the commands using the following syntax

grep '^firefox|' logfile | cut -f2- -d"|"

to get a report that would look like this:

 2025-09-12_15:55 | 2.4    3493 username /opt/firefox/firefox
 2025-09-12_15:56 | 2.4    3493 username /opt/firefox/firefox
 2025-09-12_15:57 | 2.4    3493 username /opt/firefox/firefox
 2025-09-12_15:58 | 2.3    3493 username /opt/firefox/firefox
 2025-09-12_15:59 | 2.4    3493 username /opt/firefox/firefox
 2025-09-12_16:00 | 2.4    3493 username /opt/firefox/firefox
 2025-09-12_16:01 | 2.5    3493 username /opt/firefox/firefox
2 Likes

A lot of good scripts.

The high CPU usage also occurs when Firefox is not running.

I am trying out your script now.

I do not know what to do so I can get a logfile.

"--mincpu" )
minCpu=$2 ;
shift ; shift ;
;;
"--watch" )

I was not blaming Caja.

I was giving input.

Use the command in the form:

OS_Admin__MonitorUsage_CPU.sh    --mincpu 1.0  >${pathToLogfile}
1 Like

Your title was pointing directly at Caja:

Why is Caja using 40% of my CPU?

1 Like

It was using 40% of my cpu. ??