The Story

The Great Cron Job Mystery: When Variables Go AWOL

There I was, 2 AM on a Thursday, staring at logs that made absolutely zero sense. Every cron job was running perfectly - showing "SUCCESS" in the logs - but every single Redis operation was failing with connection errors.

The maintenance service was supposed to clean up stale jobs. The email sync was supposed to process incoming messages. The newsletter generator was supposed to... well, generate newsletters. All of them were running. None of them were working.

Redis Client Error: getaddrinfo ENOTFOUND undefined port 6379

"Undefined"? What kind of host name is "undefined"? I knew the Redis container was running because I could connect to it manually. The environment variables were set in .env.cron. Everything looked right.

Then it hit me at 2:47 AM. The kind of realization that makes you question your entire career choice.

Environment variables weren't being exported to child processes in the cron environment.

Here's the difference between code that works and code that makes you contemplate a career in goat farming:

## BROKEN: Variables only exist in current shell
source .env.cron
node scheduler.js # Redis connection fails - REDIS_HOST is undefined

## FIXED: Export all variables to child processes  
set -a          # Enable auto-export of variables
source .env.cron # Now ALL variables get exported
set +a          # Disable auto-export (good practice)
node scheduler.js # Success! Redis connects properly

That set -a flag tells bash to automatically export every variable assignment that follows. Without it, sourcing .env.cron just sets variables in the current shell - but Node.js runs in a child process that can't see them.

Four hours of debugging. The solution was literally three characters: -a.

Next time I'll remember that cron environments are basically amnesic shells that forget everything you don't explicitly tell them to remember. (I won't remember this lesson at 2 AM next week, but that's future T's problem.)

Walk safe,

-T t@toolstac.com

Related Tools & Recommendations

news
Popular choice

Morgan Stanley Open Sources Calm: Because Drawing Architecture Diagrams 47 Times Gets Old

Wall Street Bank Finally Releases Tool That Actually Solves Real Developer Problems

GitHub Copilot
/news/2025-08-22/meta-ai-hiring-freeze
60%
tool
Popular choice

Python 3.13 - You Can Finally Disable the GIL (But Probably Shouldn't)

After 20 years of asking, we got GIL removal. Your code will run slower unless you're doing very specific parallel math.

Python 3.13
/tool/python-3.13/overview
57%
news
Popular choice

Anthropic Raises $13B at $183B Valuation: AI Bubble Peak or Actual Revenue?

Another AI funding round that makes no sense - $183 billion for a chatbot company that burns through investor money faster than AWS bills in a misconfigured k8s

/news/2025-09-02/anthropic-funding-surge
52%
news
Popular choice

Anthropic Somehow Convinces VCs Claude is Worth $183 Billion

AI bubble or genius play? Anthropic raises $13B, now valued more than most countries' GDP - September 2, 2025

/news/2025-09-02/anthropic-183b-valuation
50%
news
Popular choice

Apple's Annual "Revolutionary" iPhone Show Starts Monday

September 9 keynote will reveal marginally thinner phones Apple calls "groundbreaking" - September 3, 2025

/news/2025-09-03/iphone-17-launch-countdown
47%
tool
Popular choice

Node.js Performance Optimization - Stop Your App From Being Embarrassingly Slow

Master Node.js performance optimization techniques. Learn to speed up your V8 engine, effectively use clustering & worker threads, and scale your applications e

Node.js
/tool/node.js/performance-optimization
45%
news
Popular choice

Anthropic Hits $183B Valuation - More Than Most Countries

Claude maker raises $13B as AI bubble reaches peak absurdity

/news/2025-09-03/anthropic-183b-valuation
42%
news
Popular choice

OpenAI Suddenly Cares About Kid Safety After Getting Sued

ChatGPT gets parental controls following teen's suicide and $100M lawsuit

/news/2025-09-03/openai-parental-controls-lawsuit
40%
news
Popular choice

Goldman Sachs: AI Will Break the Power Grid (And They're Probably Right)

Investment bank warns electricity demand could triple while tech bros pretend everything's fine

/news/2025-09-03/goldman-ai-boom
40%
news
Popular choice

OpenAI Finally Adds Parental Controls After Kid Dies

Company magically discovers child safety features exist the day after getting sued

/news/2025-09-03/openai-parental-controls
40%
news
Popular choice

Big Tech Antitrust Wave Hits - Only 15 Years Late

DOJ finally notices that maybe, possibly, tech monopolies are bad for competition

/news/2025-09-03/big-tech-antitrust-wave
40%
news
Popular choice

ISRO Built Their Own Processor (And It's Actually Smart)

India's space agency designed the Vikram 3201 to tell chip sanctions to fuck off

/news/2025-09-03/isro-vikram-processor
40%
news
Popular choice

Google Antitrust Ruling: A Clusterfuck of Epic Proportions

Judge says "keep Chrome and Android, but share your data" - because that'll totally work

/news/2025-09-03/google-antitrust-clusterfuck
40%
news
Popular choice

Apple's "It's Glowtime" Event: iPhone 17 Air is Real, Apparently

Apple confirms September 9th event with thinnest iPhone ever and AI features nobody asked for

/news/2025-09-03/iphone-17-event
40%
tool
Popular choice

Amazon SageMaker - AWS's ML Platform That Actually Works

AWS's managed ML service that handles the infrastructure so you can focus on not screwing up your models. Warning: This will cost you actual money.

Amazon SageMaker
/tool/aws-sagemaker/overview
40%
tool
Popular choice

Node.js Production Deployment - How to Not Get Paged at 3AM

Optimize Node.js production deployment to prevent outages. Learn common pitfalls, PM2 clustering, troubleshooting FAQs, and effective monitoring for robust Node

Node.js
/tool/node.js/production-deployment
40%
alternatives
Popular choice

Docker Alternatives for When Docker Pisses You Off

Every Docker Alternative That Actually Works

/alternatives/docker/enterprise-production-alternatives
40%
howto
Popular choice

How to Run LLMs on Your Own Hardware Without Sending Everything to OpenAI

Stop paying per token and start running models like Llama, Mistral, and CodeLlama locally

Ollama
/howto/setup-local-llm-development-environment/complete-setup-guide
40%
news
Popular choice

Meta Slashes Android Build Times by 3x With Kotlin Buck2 Breakthrough

Facebook's engineers just cracked the holy grail of mobile development: making Kotlin builds actually fast for massive codebases

Technology News Aggregation
/news/2025-08-26/meta-kotlin-buck2-incremental-compilation
40%
howto
Popular choice

Build Custom Arbitrum Bridges That Don't Suck

Master custom Arbitrum bridge development. Learn to overcome standard bridge limitations, implement robust solutions, and ensure real-time monitoring and securi

Arbitrum
/howto/develop-arbitrum-layer-2/custom-bridge-implementation
40%

Recommendations combine user behavior, content similarity, research intelligence, and SEO optimization