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.
Run the command 'rclone version' and share the full output of the command.
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
#!/bin/bash
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
# and DELETE YOUR FILES!
# Make sure to set this to the local path you are moving from!!
LOCAL=/local
# 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
[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.
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.
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.
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.