Learn how to use Doppler with your cron jobs.

This guide will show you how to use Doppler to provide secrets to cron jobs in production environments.

Setup Project Directories

The easiest way to use Doppler with Cron is to use the Doppler CLI to configure a predefined service token you want Doppler to use for a specific directory (i.e., scope) in advance. For example:

doppler configure set token $SERVICE_TOKEN --scope /path/to/some/directory

Do this for any projects you may want to execute your cron jobs for.

Use Doppler in Your Cron Job

Now, to execute a cron job command that uses the Doppler CLI with the appropriate permissions, you'll take advantage of the --scope parameter.

* * * * * doppler run --scope /path/to/some/directory -- $YOUR_COMMAND_HERE

This will cause Doppler to run in the scope of the specified path, which will cause it to use the service token you ran doppler setup with at that location.

Using this method will allow you to setup any number of potential service token credentials for your jobs without having to hardcode DOPPLER_TOKEN values into your cron jobs or otherwise worry about injecting that into your environment.

Did this page help you?