Code Monkey home page Code Monkey logo

logmailer's Introduction

LogMailer

Requires msmtp installed on a linux machine.

Goal

The goal of this script is to send the log-files of the current day to a specified email address.

Not the log files from /var/log/, but only the ones from my scripts, which I store in /home/myuser/cronjobs/logs/ on my ubuntu cloud server(s).

My log-files are named as follows: name of app, underscore, weekday (3 characters), and followed by .log.
Example: tweeps_SAT.log. The next Saturday the log-file gets overwritten.

msmtp

msmtp is a very simple and easy to use SMTP client with fairly complete sendmail compatibility.

To Do: adde installation and configuration information here.

Code

Configuration

In config-sample.py you will find the constants that the script needs to run on your server:

  • the destination email address
  • the location (absolute path) of the log directory
DEST_EMAIL = "[email protected]"
LOG_DIR = "/home/myuser/cronjobs/logs/"

Script

Cron

I have configured crontab so that the script runs twice a day: at 10 past 11 am and 10 past 11 pm.

10 11,23 * * * python3 /home/j0h4n/cronjobs/logmailer/logmailer.py > /dev/null 2>&1

To Do

Add logging to the script.

logmailer's People

Contributors

jmares avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.