Skip to content

Instantly share code, notes, and snippets.

@werrpy
Created February 21, 2020 19:05
Show Gist options
  • Save werrpy/7cf2f53301174db4167e3dcf7bb7d887 to your computer and use it in GitHub Desktop.
Save werrpy/7cf2f53301174db4167e3dcf7bb7d887 to your computer and use it in GitHub Desktop.
crontab demo
*/30 * * * * /USER/bin/example.sh >/dev/null 2>&1
#!/bin/bash
# directories
MY_DIR=/USER/NEW
# paths
RCLONE=/USER/bin/rclone
RCLONE_CONFIG=/USER/config/rclone.conf
# used to detect running commands
function ppgrep() { pgrep "$1" | xargs --no-run-if-empty ps fp; }
# copy some data
function copy_data() { $RCLONE --config $RCLONE_CONFIG copy "$MY_DIR" my-remote: > /dev/null 2>&1; }
# make sure the command is not running
if [[ ! -n $(ppgrep "rclone" | grep -e "copy $MY_DIR") ]]; then
# run it
copy_data
fi
@werrpy
Copy link
Author

werrpy commented Feb 24, 2020

This will try to run an rclone copy every 30 minutes. If a copy is still in progress, it will skip and try again in 30 minutes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment