Using CronitorCLI

CronitorCLI is the recommended companion application to our monitoring service. Run it locally to view your job status from your terminal and deploy it to your server for helpful features like:

  • Automatically discover cron jobs and import them into Cronitor for monitoring
  • Watch crontab files for updates and push schedule changes to Cronitor automatically
  • Send telemetry pings to Cronitor when your jobs run that include exit code, job output, duration, hostname, and more

Installation

CronitorCLI is packaged as a single executable for Linux, MacOS and Windows.

Paste each instruction into a terminal and execute. Where the placeholder /path/to is used, replace with your desired location for the cronitor executable.
wget https://cronitor.io/dl/cronitor-cli-stable-linux-amd64.tgz
tar xvf cronitor-cli-stable-linux-amd64.tgz -C /path/to/cronitor
/path/to/cronitor configure --api-key <API-KEY>
Paste each instruction into a terminal and execute. Where the placeholder /path/to is used, replace with your desired location for the cronitor executable.
curl -O https://cronitor.io/dl/cronitor-stable-darwin-amd64.zip
unzip cronitor-stable-darwin-amd64.zip -d /path/to/
/path/to/cronitor configure --api-key <API-KEY>
  1. Download application: https://cronitor.io/dl/cronitor-stable-windows-amd64.zip
  2. Unzip and move the executable to %ProgramFiles%\ for system-wide use
  3. Run %ProgramFiles%\cronitor.exe configure --api-key <API-KEY> from PowerShell or cmd.

Usage

$ cronitor
CronitorCLI version 16.0

Command line tools for Cronitor.io. See https://cronitor.io/docs/using-cronitor-cli for details.

Usage:
  cronitor [command]

Available Commands:
  activity    View monitor activity
  configure   Save configuration variables to the config file
  discover    Attach monitoring to new cron jobs and watch for schedule updates
  exec        Execute a command with monitoring
  help        Help about any command
  ping        Send a single ping to the selected endpoint
  status      View monitor status
  update      Update to the latest version

Flags:
  -k, --api-key string        Cronitor API Key
  -c, --config string         Config file
  -h, --help                  Help for cronitor
  -n, --hostname string       A unique identifier for this host (default: system hostname)
  -l, --log string            Write debug logs to supplied file
  -p, --ping-api-key string   Ping API Key
  -v, --verbose               Verbose output

Use "cronitor [command] --help" for more information about a command.

Running CronitorCLI on your server

If you're using Cronitor to monitor traditional cron jobs, cronitor discover is the easiest way to create monitors and keep their schedule in sync with your server. If you're monitoring Windows scheduled tasks, scripts, daemons, ETL processes or almost anything else, using CronitorCLI for cronitor exec and cronitor ping will send telemetry pings more reliably than simply using Curl.

  • Required configuration can be provided as environment variables or from a json file. See Configuration later in this document for details.
  • Update easily to the latest version with a simple cronitor update command.
  • Install CronitorCLI in a system-wide location to more easily monitor tasks running as different users.

Running CronitorCLI on your local machine

Running CronitorCLI on your local machine enables quick commandline access to your Cronitor account.

  • Use cronitor status to view your current Cronitor dashboard details from your terminal
  • View and query monitor activity using cronitor activity. Use the optional --before [timestamp] param to paginate results.
  • Like server deployment, update easily to the latest version with a simple cronitor updatecommand.

Configuration

Configuration variables like api key and current server hostname can be provided as runtime arguments or environment variables. Alternatively, the configure command can be used to save configuration variables to a file.

Name Argument Variable name
Monitor API Key -k, --api-key [key] CRONITOR_API_KEY
Ping API Key -p, --ping-api-key [key] CRONITOR_PING_API_KEY
Current server name -n, --hostname [name] CRONITOR_HOSTNAME
Log Cronitor activity --log [path] CRONITOR_LOG
Exclude from name -e, --exclude-from-name [substring] CRONITOR_EXCLUDE_TEXT
Config file to use -c, --config [path to file] CRONITOR_CONFIG

Platform Default config file location
Linux /etc/cronitor/cronitor.json
MacOS /etc/cronitor/cronitor.json
Windows %SystemDrive%\ProgramData\Cronitor\cronitor.json