I want an rclone backup task to run every day at 6pm. The cronjob I set up for it is however not working. I browsed the forum and the internet to learn how to work with crontab and managed to run test scripts, so the basics are working. I also gave "cron" permissions and made the sh.file executable with chmod +x. However, as soon as I add my rclone command to the cronjob or a shell script containing the rclone command, nothing executes.
Run the command 'rclone version' and share the full output of the command.
rclone v1.59.0
os/version: darwin 12.4 (64 bit)
os/kernel: 21.5.0 (x86_64)
os/type: darwin
os/arch: amd64
go/version: go1.18.3
go/linking: dynamic
go/tags: none
Which cloud storage system are you using? (eg Google Drive)
Google Drive
The command you were trying to run (eg rclone copy /tmp remote:tmp)
This is a the shell-script (Pidof was installed via homebrew):
#!/bin/bash
if pidof -o %PPID -x βCronjob\ β\ All\ Volumes\ Unencrypted.shβ; then
exit 1
fi
rclone sync /Volumes/ jhdrive:/Backups/Unencrypted/ --transfers=5 --copy-links --create-empty-src-dirs --filter-from /Users/jan/Library/Mobile\ Documents/com\~apple\~CloudDocs/Rclone/Backups/Filter\ β\ All\ Volumes\ Unencrypted.txt --log-level INFO --log-file /Users/jan/Library/Mobile\ Documents/com\~apple\~CloudDocs/Rclone/Logs/Log\ β\ All\ Volumes\ Unencrypted.log --rc
Hello, I tried to follow your suggestions. My sh-file looks like this now. I'm not sure how to incorporate the debug log though for the version command.
#!/bin/bash
if -o %PPID -x β/Users/jan/Library/Mobile\ Documents/com\~apple\~CloudDocs/Rclone/Backups/Cronjob\ β\ All\ Volumes\ Unencrypted.shβ; then
exit 1
fi
rclone version
exit
--- make sure the .sh file runs from the command line.
--- need to change the location of the log file
--- this is what i would test, again, without the pid stuff
#!/bin/bash
rclone version --log-level=DEBUG --log-file=/path/to/log.txt
--- the formatting cron jobs entry, looks a bit strange/confusing, using space character without using enclosing quotes and both slashes, forward and backward?
--- perhaps keep the .sh in the /tmp dir
--- how did you create the cron entry; given that .sh script is to be run as root? https://mkyong.com/linux/linux-how-to-run-cron-job-as-root/
--- use a very simple command
#!/bin/bash
echo test > /tmp/test.txt
--- make sure rclone can find and access the rclone.conf file.
maybe hardcode using --config=/path/to/rclone.conf
Exactly, the test scripts were exactly what you wrote down there (echo test...). And they worked. Even with the .sh in that directory.
Yes, I had sudo in the command, but that wasn't working either, so I removed it. Now it's just the time ***** plus the path to the script.
This is how I run rclone commands on Mac, I put the paths into Terminal first so I am sure they are correct and then implement these paths into the rclone command. When I run the rclone command purely in Terminal, everything works fine. Just in the cronjob scenario, things don't work anymore.
I created it with Mac Terminal with "crontab -e", then pressing "i" and then editing it.
In general I haven't found a working solution here not the forum nor on the web of how automating rclone tasks, like each day at a specific time for example.
I'd be happy for some resources/solutions of alternative ways if there are any.
since it reduces the chances of me messing up bash escapes. It also makes it easier to comment and format the call.
Test it when you can. I've had issues on macOS but on Linux, I've used something like this or this. Not sure what it would take to make it work on macOS
Thanks so much Justin. This solution worked for me. I think you delivered two great blue-prints for automating rclone tasks on Mac to the community here.
to expand on @jwink3101 idea,
--- i have a python script that creates commands for rclone, 7zip, fastcopy, VSS.
about the function DoCmd, that runs the commands:
--- captures the stdout/stderr and logs that to text files.
---- if your rclone config file is crypted, need to pass that password to rclone.
that is handled by input