Skip to content

Instantly share code, notes, and snippets.

@cage1016
Last active February 27, 2020 07:04
Show Gist options
  • Save cage1016/9c842a428990adba2d9b45d0d435cd76 to your computer and use it in GitHub Desktop.
Save cage1016/9c842a428990adba2d9b45d0d435cd76 to your computer and use it in GitHub Desktop.
mask-9999
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
#*/1 * * * * /root/project/data-broker/run.sh >> /tmp/run.log
# sync by 30 seconds
* 0-15,22-23 * * * ( sleep 1; /root/project/data-broker/run.sh >> /tmp/run.log)
* 0-15,22-23 * * * ( sleep 31; /root/project/data-broker/run.sh >> /tmp/run.log)
# footgun, clear old pharmacy table
*/30 * * * * /root/project/data-broker/footgun.sh >> /tmp/footgun.log
#* * * * * /root/project/data-broker/a.sh
#* * * * * ( sleep 30 ; /root/project/data-broker/a.sh)
#!/bin/bash
# call hook
echo ===========================
echo Call GAE footgun hook...
#curl -X POST https://test-dot-pharmacy-dot-mask-9999.appspot.com/api/pharmacies/footgun
curl -X POST https://mask-9999.appspot.com/api/pharmacies/footgun
echo ""
#!/bin/bash
TARGET_BUCKET=gs://mask-9999-pharmacies
TARGET_BUCKET2=gs://mask-9999-pharmacies
PRJ_HOME=/root/project/data-broker/pharmacies
DATA_PATH=$PRJ_HOME/json/points.json
cd $PRJ_HOME
echo Job start `date`
echo Pull from github
git pull
#curl -X POST https://mask-9999.appspot.com/api/sync
echo ===========================
echo Sync data to GCS...
gsutil cp -r $DATA_PATH $TARGET_BUCKET/points.json
# call hook
echo ===========================
echo Call GAE hook...
#curl -X POST https://mask-9999.appspot.com/api/sync
curl -X POST https://mask-9999.appspot.com/api/pharmacies/sync_handler
#curl -X POST https://test-dot-pharmacy-dot-mask-9999.appspot.com/api/pharmacies/sync_handler
# backup
echo ===========================
echo backup point.json
gsutil cp -r $DATA_PATH $TARGET_BUCKET2/backup/`date +%Y_%m%d_%H%M%S.json`
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment