first commit
This commit is contained in:
9
data/apidemo-cron/build/Dockerfile
Normal file
9
data/apidemo-cron/build/Dockerfile
Normal file
@@ -0,0 +1,9 @@
|
||||
FROM ubuntu:22.04
|
||||
|
||||
RUN apt-get update && apt-get -y upgrade
|
||||
RUN apt-get -y install cron curl jq dos2unix
|
||||
|
||||
COPY entrypoint.sh /opt/entrypoint.sh
|
||||
RUN dos2unix /opt/entrypoint.sh ; chmod +x /opt/entrypoint.sh
|
||||
|
||||
CMD ["sh", "/opt/entrypoint.sh"]
|
||||
8
data/apidemo-cron/build/entrypoint.sh
Normal file
8
data/apidemo-cron/build/entrypoint.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
dos2unix $COMMAND
|
||||
|
||||
echo "$SCHEDULE $USER $COMMAND" > /etc/cron.d/api-cronjob
|
||||
chmod 0644 /etc/cron.d/api-cronjob
|
||||
crontab /etc/cron.d/api-cronjob
|
||||
touch /var/log/cron.log
|
||||
env > /etc/environment && cron -f
|
||||
5
data/apidemo-cron/scripts/get_cryptocurrency.sh
Normal file
5
data/apidemo-cron/scripts/get_cryptocurrency.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
DATE=`date +"%Y-%m-%d"`
|
||||
curl https://api.coindesk.com/v1/bpi/currentprice.json > /tmp/cryptocurrency.json
|
||||
jq -c 'del(.disclaimer)' /tmp/cryptocurrency.json >> /opt/output/cryptocurrency_$DATE.json
|
||||
find /opt/output/ -mtime +5 -delete
|
||||
Reference in New Issue
Block a user