Score:0

OneDrive service keeps stopping on Ubuntu on Raspberry Pi

gi flag

I have installed a OneDrive client onedrive v2.4.22-1+np1 (https://github.com/abraunegg/onedrive) on an Ubuntu server (Ubuntu 22.04.1) which is running on a Raspberry Pi 4.

After installation I have started the service via

systemctl --user enable onedrive
systemctl --user start onedrive 

Synchronization with OneDrive works as expected as long as I'm logged in. When I leave the system alone it stops synchronization after some time. There is another service running on the system which relies on the synchronization. This service works still fine but produces outdated results due to lacking synchronization and the results are not visible in the cloud.

When I login into the server on the Raspberry via SSH and get the service status via systemctl --user status onedrive right after login, I can see that the onedrive client started just after my login while it should have been running continuously without my login:

Dec 14 12:45:27 raspi-server onedrive[19550]: Configuration file successfully loaded
Dec 14 12:45:27 raspi-server onedrive[19550]: Notification (dbus) server not available, disabling
Dec 14 12:45:28 raspi-server onedrive[19550]: Configuring Global Azure AD Endpoints
Dec 14 12:45:29 raspi-server onedrive[19550]: Initializing the Synchronization Engine ...
Dec 14 12:45:29 raspi-server onedrive[19550]: Initializing monitor ...
Dec 14 12:45:29 raspi-server onedrive[19550]: OneDrive monitor interval (seconds): 300
Dec 14 12:45:29 raspi-server onedrive[19550]: Starting a sync with OneDrive

According to the documentation at https://github.com/abraunegg/onedrive/blob/master/docs/USAGE.md#how-to-run-a-user-systemd-service-at-boot-without-user-login I should install the service using commands systemctl --user enable onedrive and systemctl --user start onedrive, but with su - root first. I get an authentification error using su - root. If I do it without elevated rights, the synchronisation works but stops when I'm not logged in. If I use sudo systemctl --user enable onedrive instead of using su - root, I get the error message Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=<user>@.host --user to connect to bus of other user). The linked documentation deals with a similar error message, and for Ubuntu on Raspberry Pi the first step according to the documentation is "Create a symbolic link from /home/root/.config/onedrive pointing to /root/.config/onedrive/". But I have neither a directory /home/root/ nor /root/.config/, so I'm stuck here.

I don't know how to figure out what's wrong with my service configuration. How can I make the onedrive service to work continuously?

Edit:

The missing piece was the terminal command loginctl enable-linger <your_user_name> which I took from the accepted answer point 4. With this, it now works like a charm.

Score:0
kr flag

Disclosure: I am the developer of the OneDrive Client for Linux - https://github.com/abraunegg/onedrive

If I do it without elevated rights, the synchronisation works but stops when I'm not logged in.

The correct process to do this is below:

  1. Login as a non-root user.

  2. Configure the application for your requirement and validate it is working using --synchronize --dry-run for a 1 time sync

  3. Enable and start the service required for your non-root user as per https://github.com/abraunegg/onedrive/blob/master/docs/USAGE.md#onedrive-service-running-as-a-non-root-user-via-systemd-with-notifications-enabled-arch-ubuntu-debian-opensuse-fedora

    systemctl --user enable onedrive; systemctl --user start onedrive

  4. Enable your user account to linger as per https://github.com/abraunegg/onedrive/blob/master/docs/USAGE.md#how-to-run-a-user-systemd-service-at-boot-without-user-login

    loginctl enable-linger <your_user_name>

This is the correct process to use and has been validated many times.

Additionally, in future, please raise a discussion point here: https://github.com/abraunegg/onedrive/discussions to ask questions like this.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.