1

I'm currently having a bit of a nightmare as the company secretary's Mac has failed to run OneDrive since June. I use this to sync a Sharepoint document store that is effectively the company file server. The secretary has been working on a fairly significant number of files (and some pretty important ones regarding finance/invoices, recruitment, payroll, etc,) and did not noticed/mentioned that OneDrive hasn't been running.

Because of this problem, I've got ~500 files that I need to identify and work out how to sync/merge without over writing other people's changes... :/

I've effectively fixed her OneDrive for the time being -- it starts at startup and logs in and syncs as expected. I'm nervous, however, that OneDrive will stop again and we'll be back in the same boat, and I don't feel that asking her to keep an eye on it is a long term or a reliable solution.

What I was thinking of doing was to write a script that monitors for the OneDrive process and will fire an alert of some kind if it's not running. I am not a Mac expert however so I'm at a bit of a loss as how best to achieve that.

I guess AppleScript and a cron job is my best option. Can anyone advise if there is a better method, and can anyone help me getting started with AppleScript to detect a process and send an email warning if it's not detected?

EDIT : Process name is OneDrive

  • Please add the process name. – JBis Aug 15 '18 at 15:00
  • I don’t think the problem is OneDrive process being stopped. It’s more likely to be running and not signed in. – Allan Aug 15 '18 at 16:23
  • Who knows, by the time she brought it to me the process wasn't running, wasn't starting on startup AND it wasn't logged in. – Patrick Aug 15 '18 at 16:25
3

IMO your best bet would be to use launchd to make sure that OneDrive is always running no matter what.

(launchd is a bit like cron but much more powerful.)

Save this file as ~/Library/LaunchAgents/com.tjluoma.keep-onedrive-alive.plist (where ~ is the home directory on the secretary's computer):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>com.tjluoma.keep-onedrive-alive</string>
    <key>Program</key>
    <string>/Applications/OneDrive.app/Contents/MacOS/OneDrive</string>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

Then load it in launchd using this command:

launchctl load ~/Library/LaunchAgents/com.tjluoma.keep-onedrive-alive.plist

That will:

a) Launch OneDrive

b) Re-Launch OneDrive if it is quit or crashes. Basically anytime it stops running, it will automatically start again.

Note that you should UN-check the option in OneDrive's preferences to open at login, because launchd will be in charge of running it.

OneDrive Preferences

  • Excellent point! Upvoting already, despite the incompleteness (so far) of this answer. – Harald Hanche-Olsen Aug 15 '18 at 14:48
  • Mate, can't thank you enough for the effort you put in here. I'd got as far as an applescript that worked in terminal but couldn't get it to execute in cron. You've solved my problem though. Can I ask how you made the plist? I was initially directed to a paid-for app to do that so I avoided. – Patrick Aug 15 '18 at 15:41
  • I used LaunchControl to make it. I write a bunch of these, so it's something I've paid for ages ago. There's also Lingon X which has been around forever and it also good, but I haven't used in awhile. – TJ Luoma Aug 15 '18 at 16:56

You must log in to answer this question.

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