rclone failed to sync file with crontab job

This document record my solution to using rclone to sync files from local machine to Google Driver failed issue when start the job from crontab.

rclone failed to sync file with crontab job

I am writing a bash script to sync files from local directory to Google Drive with rclone, but I encounter an issue what the script can run directly from the terminal but the crontab job failed to sync files, it seems hang, the output message was like below:

Elapsed time:         0.5sTransferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Elapsed time:         1.0sTransferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Elapsed time:         1.5sTransferred:   	          0 B / 0 B, -, 0 B/s, ETA -

After half an hour, it still not check the files, and finally I find the issue was that it needs Full Disk permission for the rclone, after I login to the remote server and find that it has a dialog from rclone request permission.

The problem for my case was that I run the command on the remote Mac machine, and I usually login to the remote machine with ssh from terminal, and I rarely login to the desktop of the machine.

Solution

Grant Full Disk permission to the rclone application from System Setting.

Start the crontab job again, and it can run successfully.

So to test the crontab job, we need to test the script from crontab, we can update the crontab trigger time to the next minute and it will run soon so we can check the script can run successfully or not.