1

I recently installed Grive, a third party Google Drive tool for Ubuntu, and in order to sync the folders, you must run the command grive in the Google Drive folder in your home page. Is there a way I can automate a simple command before my system shuts down to ensure I always sync my libraries?

Thanks!

bross
  • 591
  • 2
  • 5
  • 7

1 Answers1

1

As mentioned by Warrent Hill, Execute command before shutdown/reboot is the way to do it. Create a script under /etc/init.d/shutdown_google_drive.sh and add softlinks as required in rc6.d.

However, if the synchronization may take over 60 seconds (I'm pretty sure this is the default timeout,) then it won't work because the shutdown process has a watchdog and a script that takes too long is simply stopped (as in killed) and the shutdown process moves on.

To make sure you do not lose data, you may consider using shutdown -c in your script (I would think it's possible) and let the user know that the shutdown was cancelled in the event your sync-ing is taking too much time.

Alexis Wilke
  • 2,707