Created
September 2, 2020 10:22
-
-
Save asraful/0c930d8e942d3c9533d51e8c5538e4ca to your computer and use it in GitHub Desktop.
Write a cron job used in EC2 to backup data from ec2 to certain s3 bucket
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/sh | |
| WK_DIRECTORY=$1 | |
| WK_BUCKET=$2 | |
| JOB_INTERVAL=$3 | |
| pip install --user awscli --upgrade | |
| command="/usr/local/bin/aws s3 sync $WK_DIRECTORY s3://$WK_BUCKET" | |
| echo $command | |
| job="*/$JOB_INTERVAL * * * * $command" | |
| echo "$job" | |
| crontab -l | { cat; echo "$job"; } | crontab - |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment