Created
February 21, 2020 19:05
-
-
Save werrpy/7cf2f53301174db4167e3dcf7bb7d887 to your computer and use it in GitHub Desktop.
crontab demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*/30 * * * * /USER/bin/example.sh >/dev/null 2>&1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.