toFrankie / blog

种一棵树,最好的时间是十年前。其次,是现在。
20 stars 1 forks source link

iCloud 云盘同步卡住的解决方法 #345

Open toFrankie opened 1 month ago

toFrankie commented 1 month ago

配图源自 Freepik

在一定程度上来说,Apple 生态确实做得很不错。

但是 iCloud Drive 就是一坨屎,经常性同步卡死...

比如这样,它可以卡到天荒地老... :anger:

一搜,全是这类问题:

先到 Apple 官网(戳我),确认 iCloud 云盘服务有没崩。

然后官方客服可能会让你关掉 iCloud 云盘同步,重新打开,但如果是 iCloud 云盘重度用户,文件容量特别多的话,你得想想重新下载的痛苦,而且 iCloud 下载的速度还...

[!NOTE] 以下提供一些「可能」有效的方法,实际全凭天意。

杀掉进程

终端下先后执行以下命令,然后重新打开 Finder。

$ killall bird
$ killall cloudd

bird 是什么?

$ man bird
BIRD(8)                                       System Manager's Manual                                       BIRD(8)

NAME
     bird – Documents in the Cloud

SYNOPSIS
     bird

DESCRIPTION
     bird is one of the system daemons backing the Documents in the Cloud feature.

     There are no configuration options to bird, and users should not run bird manually.

SEE ALSO
     brctl(1)

Mac OS X                                              22/04/14

调整进程优先级

  1. 执行 ps aux | grep bird,会看到类似的输出。其中 4137 为进程 ID(PID)。
$ ps aux | grep bird
frankie           4137   0.0  0.1 33705140  10160   ??  S     4:01下午   0:06.68 /System/Library/PrivateFrameworks/CloudDocsDaemon.framework/Versions/A/Support/bird
  1. 执行 ps -fl -C <PID> 查看某进程优先级。其中 NI 是指 nice 值,表示一个进程的优先级。
$ ps -fl -C 4137
  UID   PID  PPID   C STIME   TTY           TIME CMD                     F PRI NI       SZ    RSS WCHAN     S             ADDR
  501  4137     1   0  4:01下午 ??         0:06.68 /System/Library/  1004004  31  0 33704616  10244 -      S                   0
  1. 执行 sudo renice -n -10 -p <PID> 调整某个进程优先级。
$ sudo renice -n -10 -p 4137

负数优先级更高,据说 -20 最高,但不建议,这里使用 -10(参考这里)。

根据以上自定义两个 alias,可添加到 .bash_profile.zshrc 里。

alias renice_bird_process='BIRDPID=$(ps aux | grep -i bird | awk '\''{print $2}'\'' | head -1); sudo renice -n -10 -p $BIRDPID'

alias show_bird_process_priority='BIRDPID=$(ps aux | grep -i bird | grep -v grep | awk '\''{print $2}'\'' | head -1); ps -o pid,ni -p $BIRDPID'

删除 CloudDocs(慎重)

这个我未亲测,仅供参考。

$ killall bird

$ rm -rf ~/Library/Application\ Support/CloudDocs

删掉 CloudDocs 目录下所有文件,相当于把 iCloud 云盘的数据库清空,然后它会自动重启 iCloud 任务,重新上传或下载。