Run shell scripts as Cronjobs in single Docker container, Optionally use sendEmail to send emails.
455
Run shell scripts as Cronjobs in single Docker container, Optionally use sendEmail to send emails. You can define multiple shell scripts & crontabs. This supports both sh & bash shell.
scripts folder.install_crontab.txt file*/30 * * * * /sh-script.sh >> /var/log/cron.log
*/5 * * * * /bash-script.sh >> /var/log/cron.log
$ docker build -t cron-sendemail .
$ docker run --name cron-sendemail --restart always -dt cron-sendemail
$ docker-compose build
$ docker-compose up -d
$ docker logs cron-sendemail
crond: crond (busybox 1.27.2) started, log level 8
crond: USER root pid 7 cmd /sh-script.sh >> /var/log/cron.log
crond: USER root pid 9 cmd /bash-script.sh >> /var/log/cron.log
this is a sh script, ran on Tue Jan 16 10:03:00 UTC 2018
This is a bash script, ran on Tue Jan 16 10:03:00 UTC 2018
$ export [email protected] ## From addess & user email for authentication
$ export [email protected]
$ export PASSWD_EMAIL=ab12345678
$ export SMTP_EMAIL="smtp.gmail.com:587"
$ export SUBJECT_EMAIL="This should be the email subject"
$ export CONTENT_EMAIL="This is the content/body of email" ## You can give file as a content
$ sendEmail -u $SUBJECT_EMAIL -m $CONTENT_EMAIL -f $FROM_EMAIL -t $TO_EMAIL -s $SMTP_EMAIL -o tls=yes -xu $FROM_EMAIL -xp $PASSWD
ToDo - Improving sendEmail usage.
If this helps, Fork & Star it :)
Content type
Image
Digest
Size
12.4 MB
Last updated
over 8 years ago
docker pull vivekyad4v/docker-cron-sendemail-shell-scripts