dachev / node-crontab

A module for creating, reading, updating, and deleting system cron jobs
189 stars 35 forks source link

Is there a way to set MAILTO ? #15

Closed keithrz closed 9 years ago

keithrz commented 9 years ago

I have an existing crontab that I want to recreate with this library. The first line has a MAILTO command like this: MAILTO=example@test.com

full crontab -l example: MAILTO=unix_root@example.com,developer@example.com

00 09 * * * ls -l >> /opt/log/ls-output.log 2>&1

More info: http://www.cyberciti.biz/faq/linux-unix-crontab-change-mailto-settings/

bmeck commented 9 years ago

In general setting environment variables via crontab is done by calling a shell script to setup your variables and execute the main program. Some implementations of cron support env vars using -e but it is not universal. Safer to use the wrapper script.

dachev commented 9 years ago

@keithrz Why do you want to set env variables programmatically? What is your use case? At the moment I am inclined to think that this functionality is outside the scope of node-crontab which is cron job manipulation.

dachev commented 9 years ago

@keithrz Give this a try:

00 09 * * * source /path/to/a/file/with/your/env/variables && ls -l >> /opt/log/ls-output.log 2>&1