Rclone+Onedrive+cron job at boot not working

Hello there,

This may not be a rclone issue but here goes:

I'm trying to get a boot script launched by cronie to work on my Nobara 40 (= Fedora 40) PC.
It is a basic bash script to mount my Onedrive share in my home dir when my PC starts.
The script is working when I run it in a terminal. I can also run rclone mount and it does mount the drive.
However, upon rebooting my PC it doesn't work.

In cron's log files, I can see the following error message:

Sep 13 15:53:31 nobara-pc CROND[1657]: (XXX) CMD (rclone mount onedrive: /home/XXX/OneDrive --daemon)
Sep 13 15:53:36 nobara-pc CROND[1615]: (XXX) CMDOUT (2024/09/13 15:53:36 CRITICAL: Failed to create file system for "onedrive:": failed to get root: Get "https://graph.microsoft.com/v1.0/drives/XXX/root": couldn't fetch token: Post "https://login.microsoftonline.com/common/oauth2/v2.0/token": dial tcp: lookup login.microsoftonline.com on 127.0.0.53:53: server misbehaving)
Sep 13 15:53:36 nobara-pc CROND[1615]: (XXX) CMDEND (rclone mount onedrive: /home/XXX/OneDrive --daemon)

However, if I manually run the same script just after boot, it works fine.

Here's the cron job config:
@reboot /home/XXX/src/rclone-mount_onedrive.sh

Here's my script:

for i in {1..30}; do ping -c1 www.google.com &> /dev/null && break; done
rclone mount onedrive: /home/XXX/OneDrive --daemon

And here's my rclone drive onedrive config (which works on its own, as stated above):

[onedrive]
type = onedrive
token = {"access_token":"XXX"}
drive_id = XXX
drive_type = personal

Rclone version: 1.68
OS : Nobara 40

Would anyone be able to help? Thanks in advance.

welcome to the forum,

as a test, remove --daemon

maybe add a sleep 60 between the ping command and the mount command

and use a rclone debug log.

1 Like

Thanks @asdffdsa :slight_smile:

I've added a 'sleep 20' and it works! Thanks a lot for your help.
What I do not understand is that the first line of my script (taken from Internet) should yield the same result... If DNS's not up, ping should return an error and the loop should continue... Anyways, it works with your solution and I'm fine with it.
I should have read the error message more carefully. It clearly leads toward a DNS error.

I will keep the debug log rclone option in the back of my mind. Thanks again and have a good one!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.