0

I have installed Grive2 console client for Google Drive with the following steps:

sudo add-apt-repository ppa:nilarimogard/webupd8  
sudo apt-get update  
sudo apt-get install grive 

Then I created folder for sync and log-in to my Google account:

mkdir ~/GoogleDrive
cd GoogleDrive
grive -a

Then I reboot my system, and can't find any services for grive.
So I tried to investigate the file list installed by grive package:

$ dpkg -L grive
/.
/usr
/usr/lib
/usr/lib/grive
/usr/lib/grive/grive-sync.sh
/usr/lib/systemd
/usr/lib/systemd/user
/usr/lib/systemd/user/grive-changes@.service
/usr/lib/systemd/user/grive-timer@.service
/usr/lib/systemd/user/grive-timer@.timer
/usr/bin
/usr/bin/grive
/usr/share
/usr/share/doc
/usr/share/doc/grive
/usr/share/doc/grive/changelog.Debian.gz
/usr/share/doc/grive/copyright
/usr/share/man
/usr/share/man/man1

Here are 3 interesting systemd-related items:

$ dpkg -L grive | grep systemd/user/
/usr/lib/systemd/user/grive-changes@.service
/usr/lib/systemd/user/grive-timer@.service
/usr/lib/systemd/user/grive-timer@.timer

Their contents are as follows:

$ cat /usr/lib/systemd/user/grive-changes@.service
[Unit]
Description=Google drive sync (changed files)

[Service]
ExecStart=/usr/lib/grive/grive-sync.sh listen "%i"
Type=simple
Restart=always
RestartSec=30

[Install]
WantedBy=default.target

$ cat /usr/lib/systemd/user/grive-timer@.service
[Unit]
Description=Google drive sync 
After=network-online.target

[Service]
ExecStart=/usr/lib/grive/grive-sync.sh sync "%i"

$ cat /usr/lib/systemd/user/grive-timer@.timer
[Unit]
Description=Google drive sync (fixed intervals)

[Timer]
OnCalendar=*:0/5
OnBootSec=3min
OnUnitActiveSec=5min
Unit=grive-timer@%i.service

[Install]
WantedBy=timers.target

So it seems that grive has internal functionality to automate synchronization.
And there is no need to invent another bicycle with cron scheduler.

But I'm not familiar with systemd user's timers and services.

Found forum post on ArchLinux, but can't understand how to combine it with grive files.

What should I do to enable grive services and timers?

2

your question was giving me the right hint to look at the accompanying systemd user timer/service of grive2.

Only recently the answer to your question was added to the README.md on grive2 github repository. Have a look at README section on systemd-based syncs. Essentially you call:

# 'google-drive' is the name of your Google Drive folder in your $HOME directory
systemctl --user enable grive-timer@$(systemd-escape google-drive).timer
systemctl --user start grive-timer@$(systemd-escape google-drive).timer
systemctl --user enable grive-changes@$(systemd-escape google-drive).service
systemctl --user start grive-changes@$(systemd-escape google-drive).service

Regards

RA

  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Mitch Mar 3 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.