Skip to content

Instantly share code, notes, and snippets.

@brettpetch
Last active July 13, 2020 16:54
Show Gist options
  • Save brettpetch/befe1a33ce4c3f4dbb11d2430b789ca5 to your computer and use it in GitHub Desktop.
Save brettpetch/befe1a33ce4c3f4dbb11d2430b789ca5 to your computer and use it in GitHub Desktop.
#!/bin/bash
# RCLONE UPLOAD CRON TAB SCRIPT
# chmod a+x /media/sdan/ynbldgno/cron/rclone-upload.sh
# Type crontab -e and add line below (without #) and with correct path to the script
# * * * * * /media/sdan/ynbldgno/cron/rclone-upload.sh >/dev/null 2>&1
# if you use custom config path add line bellow in line 20 after --log-file=$LOGFILE
# --config=/path/rclone.conf (config file location)
# Feral config location: /media/sdan/your-username-here/.config/rclone/rclone.conf
if pidof -o %PPID -x "$0"; then
exit 1
fi
CONFIGFILE="/path/to/rclone/.config/rclone/rclone.conf"
LOGFILE="/path/rclone-upload.log"
FROM="/path/Downloads/"
TO="hawke-user:/user-Media/"
# CHECK FOR FILES IN FROM FOLDER THAT ARE OLDER THAN 15 MINUTES
if find $FROM* -type f -mmin +15 | read
then
start=$(date +'%s')
echo "$(date "+%d.%m.%Y %T") RCLONE UPLOAD STARTED" | tee -a $LOGFILE
# MOVE FILES OLDER THAN 15 MINUTES
/user/bin/rclone move "$FROM" "$TO" --transfers=20 --checkers=20 --delete-after --min-age 15m --log-file=$LOGFILE --config=$CONFIGFILE
echo "$(date "+%d.%m.%Y %T") RCLONE UPLOAD FINISHED IN $(($(date +'%s') - $start)) SECONDS" | tee -a $LOGFILE
fi
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment