I use OneDrive on my Mac devices - iPad, iPhone, iMac, mini, and MacBook (iOS 16 and various versions of macOS from Catalina to Ventura). Without fail, the OneDrive app on the Mac computers will just stop syncing.

The fix is to restart the App. When I am using the GUI, this is easy, but when I am remote (usually connected via SSH), there’s no easy way to restart the App short of rebooting. Is there. Is there a command line command to restart OneDrive?

  • Not an answer to your question, but could it be that the files on your Mac have illegal characters in the filename, which OneDrive silently refuses to sync? I thought of that as I stumbled on this script earlier which aims to resolve that. Commented Jun 28, 2023 at 20:58
  • I don’t have any files like that @SaaruLindestøkke. I make certain to use only valid characters for my files and OneDrive doesn’t give any errors. It will error out (in the GUI) giving you a list of files that couldn’t sync.
    – Allan
    Commented Jun 28, 2023 at 21:00

1 Answer 1


It would be nice to be able to simply reset the service with a command, but this requires killing the app process(es) and then restarting. I create a function which can be added to your .zshrc or .zprofile (or .bashrc or ~.bash_profile).

resetOneDrive () {
    ps -ef | grep OneDrive | grep -v grep| awk '{print $2}' | sudo xargs kill -9
    echo "Waiting for services to finish..."
    sleep 2

    echo "Restarting OneDrive..."
    open -jg /Applications/OneDrive.app

The script is pretty simple. It looks for all processes with the term “OneDrive” (excludes the grep OneDrive process) and kills them with a -9 signal. It then sleeps for two seconds to allow the processes to finish and PIDs to be removed. Then it starts the OneDrive app.

It requires sudo privileges ; it will ask you for your password at execution.

When you put this in your login file, be certain to re-source it so the changes are immediate (or close/reopen your Terminal). Just issue the command . ~/.zshrc, for example, if this is where you put the function.

  • You probably could just sudo pkill -9 OneDrive, or at least ps -ef | awk '/[O]neDrive/ { print $2 }' | xargs sudo kill -9.
    – nohillside
    Commented Jun 28, 2023 at 18:57
  • I’ll give that second command a shot @nohillside. I initially started with the pkill but it just didn’t kill both processes. I’m not sure why. Thanks!
    – Allan
    Commented Jun 28, 2023 at 19:03
  • Ah, forgot the xargs in the second version, but I'm sure you figured that out yourself :-)
    – nohillside
    Commented Jun 28, 2023 at 19:07
  • I don't have OneDrive on my Mac right now, but this reddit post suggests you can use CLI switches with the OneDrive executable, e.g. the /shutdown switch. Perhaps that's more elegant than killing the processes? Commented Jun 28, 2023 at 21:02
  • Those are Windows conventions (the slash), not *nix. The person replying was giving their experience based on Windows.
    – Allan
    Commented Jun 28, 2023 at 21:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .