Rclone is running together with Mega, but no via cron

What is the problem you are having with rclone?


I am starting to use rclone and it's really amzing. But, I can only run the jobs manually. Through cronjobs it's not working, and I can see they return an error, as below:

2023/01/27 15:30:01 NOTICE: Config file "/root/.config/rclone/rclone.conf" not found - using defaults
2023/01/27 15:30:01 Failed to create file system for "Mega_Rclone:Backups_via_rclone/games/saves/no_mans_sky": didn't find section in config file

Well, OK, that's a save game just to start the tests. :smiley:

Run the command 'rclone version' and share the full output of the command.

- os/version: arch 22.0.1 (64 bit)
- os/kernel: 5.15.89-1-MANJARO (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.19.4
- go/linking: dynamic
- go/tags: none


Which cloud storage system are you using? (eg Google Drive)


The command you were trying to run (eg rclone copy /tmp remote:tmp)

53 15 * * * root rclone copy --log-level INFO --log-file=log_rclone.txt /home/ewsg/.steam/root/steamapps/compatdata/275850/pfx/drive_c/users/steamuser/Application\ Data/HelloGames/NMS/st_76561198013897068/ Mega_Rclone:Backups_via_rclone/games/saves/no_mans_sky

The rclone config contents with secrets removed.

type = mega
user = MYEMAIL
pass = REMOVED

A log from the command with the -vv flag

Despite I set it in the command, the log file is empty.

Thanks in advance for any help.

hi again,

each linux user has its own config file.
cron runs as root.
so rclone expects a config file at /root/.config/rclone/rclone.conf

yet in that other topic we solved, you were user ewsg

so two choices.

  1. copy/move the config file
    from /home/ewsg/.config/rclone/rclone.conf
    to /root/.config/rclone/rclone.conf
  2. hardcode the config file location using --config

fwiw, i would use fullpath for --log-file

cron runs as root, but crontabs are user based and you can have any user run cron jobs as they are per user.

Is that root's crontab as @asdffdsa was suggesting or another user?

cron jobs also generally have no environment variables and no concept of paths so putting 'rclone' won't work.

So my old upload script looked like:

[felix@gemini ~]$ cat /opt/homescripts/scripts/upload_cloud
set -e

# RClone Config file
RCLONE_CONFIG=/opt/rclone/rclone.conf; export RCLONE_CONFIG

# Local Drive - This must be a local mount point on your server that is used for the source of files
# WARNING: If you make this your rclone Google Drive mount, it will create a move loop
# Make sure to set this to the local path you are moving from!!

# Exit if running
if [[ $(pidof -x "$(basename "$0")" -o %PPID) ]]; then
echo "Already running, exiting..."; exit 1; fi

# Is $LOCAL actually a local disk?
if /bin/findmnt $LOCAL -o FSTYPE -n | grep fuse; then
echo "FUSE file system found, exiting..."; exit 1; fi

# Rather than use excludes, I wanted to simplify and just have two move commands to move to Movies and TV Shows
# Adjust a few settings to stay within the Dropbox API limits

# Move to Movies Folder
/usr/bin/rclone move $LOCAL/Movies upload-movies:Movies --log-file /opt/rclone/logs/upload.log --delete-empty-src-dirs --fast-list --dropbox-chunk-size 128M --tpslimit 12 --tpslimit-burst 12 --transfers 6 --stats-one-line -v --min-age 1h

# Move to TV Folder
/usr/bin/rclone move $LOCAL/TV upload-tv:TV --log-file /opt/rclone/logs/upload.log --delete-empty-src-dirs --fast-list --dropbox-chunk-size 128M --tpslimit 12 --tpslimit-burst 12 --transfers 6 --stats-one-line -v --min-age 1h

and in cron

1 5 * * * /home/felix/scripts/upload_cloud

as it ran every night at 5:01.

that interesting,
i just assumed that, from the log, rclone was looking at root for the config.

in that case, rclone will run as user felix?

Generally, you'll have a crontabs folder.

Might be

/var/spool/cron/crontabs I think on Ubuntu

on fedora:

[root@gemini cron]# ls -al
total 4
drwx------.  2 root  root   19 Jan 21 14:24 .
drwxr-xr-x. 11 root  root  128 Jan  4 15:46 ..
-rw-------   1 felix felix 643 Jan 21 14:24 felix

so that's my user felix's crontab.

If the OP is doing a bit more work, you can drop cron entries to run as a user in the format above.

in /etc/crontab /etc/cron.d/

and that format for root would apply.

Many thanks, @asdffdsa and @Animosity022 ,

Your help and opinions were greatly appreciated.

Well, I just figured out that really just putting my user at the cronjob would do the job. The task just ran.

I think this will be the most easier here. :slight_smile:

well, in the end, there was a third choice.

in sci-fi parlance, a text book example of the gripping hand solution

1 Like

I run all my cron as one user as it's just easier for me as I always try to do the simplest solution but always advocate to do what works best for you and your use case.

Happy you got it working!

Yeah, there was three choices. :slight_smile:

The only strange thing here now is the fact that that MAILTO=myaddress@provider.tld line in crontab is not working anymore. I don't know what is happening.

Well, at least for this unique job which is using rclone. All the others I have using rsync are running fine. :sweat_smile:

I run all my cron as one user as it's just easier for me as I always try to do the simplest solution but always advocate to do what works best for you and your use case.

You're right. I'll try to sort things out here.

off topic, but with respect to @Animosity022 third solution hand.

"The Gripping Hand, which features three-armed aliens. (The third arm, "the gripping hand," is especially strong.)

1 Like

I use that as well. I'd check to validate your postfix/smtp client is properly running.

Most systems you can check if mail is having an issue in /var/log/mailllog

Great. Thanks, I will try.

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