Script to stop 'cloudd' process

My Man Mini M2 Pro has developed an issue where the ‘cloudd’ process stalls, when this happens all iCloud sync operations break on the Mac. Apple are investigating but so far have not come up with a solution.
The only way of fixing it (temporarily) is to kill the ‘cloudd’ process running under my username in the Activity Monitor. This has to be done every 20-40 minutes each time it stalls.
I’m wondering if there is any way of developing a script which can 1) check if the process has stalled and 2) kill the process if it has. Or just 2) if 1) is not possible.
I’m hoping such a script can be run automatically every so often which will save me from having to kill the process manually.
I doubt it is possible but if anyone might know how it is you guys :slight_smile:
Fingers crossed.

Bash (or zsh or whatever shell you’re using):

kill `ps -u <username>  | grep CloudKitDaemon.framework/Support/cloudd | grep -v grep | cut -w -f 3`

Explanation:

  • ps -u <username> (note: do not type in the pointy brackets, only your username) lists all currently running processes associated with your username
  • grep ...| grep -v … finds the cloudd process and removes the grep itself from the list
  • cut -w -f 3 cuts out the third column of the grep output, which is the process ID
  • and finally, `ps -u ...` feed this process ID to the kill command which then does what it’s told to do

I don’t know if kill is enough to terminate the process, perhaps you have to use kill -9 to insist. Also, you’d probably want to have cloudd restart after killing it. I don’t know if that happens automagically thanks to the daemon script or not.

As to “is it stalling” – ps can tell you something about the state a process is in. A cursory look at man ps didn’t reveal anything “stalling”, though. I’d suppose that in your case there’s a network problem (iCloud is notorious for that), which ps can’t detect. Other tools like lsof might, though.

As to “run automatically”: Add it to your crontab to have it run every so often. man crontab will tell you all the gory details.

Thanks… I tried this in terminal on the Mac and looking at the Activity Monitor the cloudd process running under my username vanished completely and didn’t show at all or restart instantly (which it does if I kill it in Activity Monitor).
However after saving a test numbers file the process had started up again. So that looks good!
I don’t know enough about ‘ps’ or ‘man’ to know what commands to use to see if the process has stalled.

Ah ha I’ve got it running by using a Shortcut on the mac to execute the command and I can schedule that to run every so often.

I guess ideally if there is a way to check if the process has stalled and only then to run the command that is a complete winner?

To update you guys - I’ve resolved my ‘DNS’ issues. It seems that the Bitdefender AV had gone rogue somehow and that was causing the issue. I disabled it last night after putting some deep thought into what could be affecting the macOS core. Everything started working and that includes iCloud and the App Store on the Mac.

I uninstalled it this morning and reinstalled and everything continues to work! I’m looking forward to telling the Apple Engineers later! :slight_smile:

Hi @dbrewood, I am using macbook air M3 and I am getting the problem as you, cloudd is eating my entire internet package (10+ GB in an hour). What is the method that you used to troubleshoot the problem?

@chandupalasith In the end I solved it by completely wiping the Mac and slowly rebuilding it over a number of months until I identified the app causing the issues, which I then stopped using.