Skip to content

Instantly share code, notes, and snippets.

@m-cakir
Created October 13, 2022 11:22
Show Gist options
  • Save m-cakir/aa1d68833e6369e44b147558cfde4c7b to your computer and use it in GitHub Desktop.
Save m-cakir/aa1d68833e6369e44b147558cfde4c7b to your computer and use it in GitHub Desktop.
cron job in docker container
version: '3.1'
services:
snscrape:
image: alpine:latest
volumes:
- ./:/usr/src/app
working_dir: /usr/src/app
entrypoint:
- ./entrypoint.sh
#!/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
#!/bin/bash
timestamp=`date +%Y/%m/%d-%H:%M:%S`
echo "[task] system path is $PATH at $timestamp"
@m-cakir
Copy link
Author

m-cakir commented Oct 13, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment