Running dbt on a Schedule with Cron
Cron can't find `dbt` or your `profiles.yml` by default. Use dbt's absolute path (from its venv), `cd` into the project, and pass `--profiles-dir` explicitly because `$HOME` isn't set.
The crontab line
0 6 * * * cd /opt/dbt_project && /opt/venv/bin/dbt run --profiles-dir /opt/dbt_project >> /var/log/dbt.log 2>&1
Use the dbt inside your virtualenv (/opt/venv/bin/dbt) so the right adapter and deps load.
--profiles-dir is the usual trap
dbt looks for profiles.yml under ~/.dbt, but cron has no $HOME, so it won't be found. Pass --profiles-dir pointing at the folder that holds your profiles.yml.
Environment-based secrets
If profiles.yml uses env_var() for warehouse passwords, set those variables in the crontab too, or source an env file before the command.
FAQ
How do I schedule dbt run with cron?
0 6 * * * cd /opt/dbt_project && /opt/venv/bin/dbt run --profiles-dir /opt/dbt_project. Use the venv dbt and pass --profiles-dir.
Why can't dbt find profiles.yml in cron?
dbt defaults to ~/.dbt but cron sets no $HOME. Add --profiles-dir pointing to the directory containing profiles.yml.
How do I pass warehouse credentials to dbt in cron?
If profiles.yml uses env_var(), export those variables in the crontab line or source an env file before calling dbt.