Grabbing the cron environment

Let’s define a job

Redirects the output of env to the ~/cron_env file:

* * * * * export JOB_VAR=A_job_variable; /usr/bin/env > ~/cron_env

Running Script With a Cron Environment Outside Cron

env -i $(cat ~/cron_env) ~/cron_var_test.sh

We’re using the -i option to create an empty
environment and prevent variable leaks from the
current shell.