0

So I found that grive2 can be used to synchronize my google drive files.

I also found a nice way to automatically sync google drive when I login to Ubuntu (16.04) desktop: Startup Application settings to sync grive

but how can I also do the automatic sync when I logout?

TmTron
  • 436

1 Answers1

0

For scheduling regular tasks crontab is a general solution. In your case the logout session should be the trigger. Here lightdm seems best I would say. You can make a bash script stating your commandline sync and insert it into the /etc/lightdm/lightdm.conf file by:

session-cleanup-script=/path/to/script

For further details another answer already exists on:

Execute a script upon logout/reboot/shutdown in Ubuntu

In case you wish to sync also at regular time intervals you can also use crontab in parallel to run your bash script. Here you need to be aware that contab also runs when you are logged out which is not needed. here you could check the username (your name) if logged in before starting the grep command:

if whoami | grep -q {yourname}; then {your grep command} ; fi;

Leo
  • 1