Configuring Cron Monitor

Cron Monitor comes with a configuration file. By default, this is at ~/.cronmonrc. This file will be created by monitor if it cannot be found.

Config Options

cronwatch offers many different configuration options that allow the user to modify what it reports and where it sends those reports.

cronwatch supports these configuration options:

Name Default Value
domain http://localhost:8000
app_url cron-monitor
timestamp False
email_list ''
email_on_bad_exit True
email_on_stderr False

domain

The domain of the Django server. By default, this is http://localhost:8000.

app_url

The url path used when including the app’s urls. By default, this is cron-monitor.

timestamp

If True, every line of output will be timestamped according to local time. Defaults to False.

email_list

A comma separated list of email addresses. On job failure, an email will be sent to these addresses.

Example:

email_list = a@a.com, b@b.com, z@z.com

email_on_bad_exit

Specifies whether an email should be sent if the exit code is not 0. The default is True.

email_on_stderr

Specifies whether an email should be sent if the job prints to stderr. The default is False.

Example Config File

Below is an example of a configuration file.:

[Server]
domain = http://localhost:8000
app_url = cron-monitor

[Logging]
timestamp = False

[Email]
email_list = hello@world.com
email_on_bad_exit = True
email_on_stderr = True

Commmand Line Options

You may want monitor to deal with different jobs in a different way. To give more granularity, monitor accepts command line options as well. These arguments take precedence over the ones in the configuration file, meaning that if an option is specified both on command line and in the config file, the command line option is used.

These options can be seen by running monitor --help, but they are also listed below.

  • --name - A name for the command. The default is the command itself
  • --config - The filename for an alternate config file.
  • --domain - The domain to send requests to.
  • --appurl - The url path where the app is installed.
  • -t or --time - Prepends a timestamp to every line of output.
  • --emails - A comma separated string of email addresses to send email to if the job fails.

Email Options

To configure when to send emails, you should use either the config file or the command line options. To configure how to send emails, you will need to use the interface provided by the web dashboard.

First, navigate to the dashboard and login with a superuser. This should expose two links, Edit Email Settings and Edit Global Emails

Edit Email Settings

Modifies settings on how to send emails.

Name Default Value
Email host localhost
Email port 25
Email host user ''
Email host password ''
Use TLS False

Email host

The host of the SMTP server used to send email. Defaults to localhost.

Email port

The port to use for the host. Default is 25.

Email host user

The username to use for the SMTP server. If left blank, Cron Monitor will not try authentication.

Email host password

The password to use for authentication. If left blank, Cron Monitor will not try authentication. For security, this password is encrypted before being stored in the database, based on the SECRET_KEY attribute in settings.py

Use TLS

Check this box if you want to use TLS.

Edit Global Emails

Whenever any job sends an email, all global email addresses are sent emails as well. By default, there are no such addresses. To add, use the Add email link. To delete, check the emails you wish to remove and click the Delete selected button.