How to Email the Output of a Node.js Cronjob

I had a Node.js script that I wanted to run automatically every day, and I wanted to receive its output via email because I am lazy. So I setup a Node.js cronjob:

Pretty obvious what the above script does – it runs foobar.js then pipes the output to mail, which emails the stdout (standard out) to [email protected] with the subject as “Foobar”. This works great on my Ubuntu 14.04 and it gives me all the console.log() output from my Node.js script.

I love JavaScript 🙂

Write a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.