Created
October 13, 2022 11:22
-
-
Save m-cakir/aa1d68833e6369e44b147558cfde4c7b to your computer and use it in GitHub Desktop.
cron job in docker container
This file contains 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
version: '3.1' | |
services: | |
snscrape: | |
image: alpine:latest | |
volumes: | |
- ./:/usr/src/app | |
working_dir: /usr/src/app | |
entrypoint: | |
- ./entrypoint.sh |
This file contains 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 | |
chmod +x task.sh | |
echo "* * * * * /bin/sh /usr/src/app/task.sh >> /usr/src/app/task.log 2>&1 | |
# This extra line makes it a valid cron" > task-scheduler.txt | |
crontab task-scheduler.txt | |
touch task.log | |
crond && tail -f task.log |
This file contains 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 | |
timestamp=`date +%Y/%m/%d-%H:%M:%S` | |
echo "[task] system path is $PATH at $timestamp" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to run a cron job inside a docker container?