Skip to content

Instantly share code, notes, and snippets.

@drblue
Last active August 21, 2024 07:44
Show Gist options
  • Save drblue/6fdc431396760f2440ce to your computer and use it in GitHub Desktop.
Save drblue/6fdc431396760f2440ce to your computer and use it in GitHub Desktop.
Fix OneDrive for Mac CPU usage
#!/bin/bash
## Fix OneDrive for Mac CPU usage
##
## Seems this is still a problem 5 years later after I created this little gist.
## I have long since stopped using OneDrive (luckily), but according to
## comments below, I have added the new path for OfficeFileCache for macOS
## Mojave (10.14) and Catalina (10.15).
## Run this on macOS Mojave (10.14) and Catalina (10.15)
find ~/Library/Containers/ -type d -name OfficeFileCache -exec rm -r {} +
## Run this if you're on pre-Mojave (< 10.14)
find ~/Library/Group\ Containers/ -type d -name OfficeFileCache -exec rm -r {} +
@DCorredorM
Copy link

DCorredorM commented Dec 1, 2021

Improved the script to kill all alive procecess regarding onedrive. If you want to reopen it you can pass ass first argument the word open and it will resatrt onedrive. Otherwise it will shut OneDrive off. This really helped me because it kills all the 'OneDrive Finder Integration' procecess that was what was overheating my computer.

## Fix OneDrive for Mac CPU usage
## 
## Seems this is still a problem 5 years later after I created this little gist.
## I have long since stopped using OneDrive (luckily), but according to
## comments below, I have added the new path for OfficeFileCache for macOS
## Mojave (10.14) and Catalina (10.15).

_open=${1:-not}

## Run this on macOS Mojave (10.14) and Catalina (10.15)
find ~/Library/Containers/ -type d -name OfficeFileCache -exec rm -r {} +

## Run this if you're on pre-Mojave (< 10.14)
find ~/Library/Group\ Containers/ -type d -name OfficeFileCache -exec rm -r {} +

# Kill one drive procecess
killall OneDrive
ps aux | grep OneDrive | awk '{print $2}' | xargs kill -9 

if [ "$_open" != "not" ]; then
	open -a OneDrive
fi

@tcutts
Copy link

tcutts commented Apr 2, 2022

High OneDrive CPU use might also be a consequence of your antivirus software's on-access scanning. I found I had huge CPU use in One Drive for the last two days, and hence found myself here. I wondered about my anti-virus (BitDefender). I switched it off temporarily, and One Drive CPU use returned to something low. I then switched BitDefender back on and OneDrive CPU use remained low. I suspect that BitDefender and One Drive syncing had got themselves into a mutually dependent loop, and switching BitDefender off broke that loop.

@drogago
Copy link

drogago commented Apr 12, 2022

In my case, I needed to reinstall all Office 365 apps. That helped for a while. I noticed that the problems returned after using software to clean my Mac. So I reinstalled it again and blocked in OneDrive all apps which can try to scan the whole storage.
I have two ideas about what may cause the problem:
First, some apps try to access all files, which creates problems. But in this situation, OneDrive should try to download all files.
So more practical is the idea that in temp files, OneDrive storage some vital information about sync status. Then cleaning apps delete the files and break OneDrive.
I am not sure if I am right. Although I reinstalled Office two weeks ago, OneDrive works correctly again from this time.

@preethamam
Copy link

preethamam commented Mar 20, 2023

I have macOS 13.2.1 and OneDrive (OD) 23.048.0305.0002 (standalone). I was tired-up of this OD for a long time since they removed the system kernel extensions support. I have over 200k files of 780 GB of data. Although, I noticed the OneDrive macOS app of 2018 was terrible with high CPU usage and memory. However, it improved over time, and after December 2021, the fileprovider (removing the system kernel extension support) messed up OD. This was the problem from the end of 2021.

I was reluctant to use OD's Files On-Demand feature on mac, as I needed them even without an internet connection. Yesterday, I reset the OD on mac, which is now on the Files On-Demand. I do not see any spike in CPU and memory usage. However, sometimes it says processing changes for an extended period of time when syncing 365 files. I will observe the behavior of Files On-Demand for some time to come up with a conclusion.

I hope this helps someone if they have a similar issue.

@emory
Copy link

emory commented Apr 30, 2023

does this manifest with extended delays in Open/Save modal dialogs with some indiciates that something is horrible wrong in XPC-space?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment