Skip to content

Idle environment shutdown policy — overnight stops, weekend pauses, and the blast radius

Non-production environments cost as much as production when they're left running. A disciplined stop/start policy can cut non-prod spend by half — provided you understand the blast radius.

Your staging environment runs 24/7 on the same shape as production “for parity.” Developers touch it between 9am and 6pm on weekdays. That’s roughly 45 active hours out of 168 in a week — 27% utilization, 73% paid-for idle. You write a stop/start policy: weeknight pause from 8pm to 7am, full weekend pause, plus a manual override slack command for any developer who needs to test off-hours. The platform bill for non-production drops by half. Three months later a developer points out the cron job stopping their environment is firing during a release window, the build queue piles up, and you learn what the blast radius actually is.

What’s happening

Stopping a cloudlet-billed environment freezes the reservation clock — you stop paying for the cloudlet floor while the environment is in stopped state. The data disks remain attached and billed (much smaller line item), so persistent state survives. Starting back up is fast, typically under 60 seconds, but it isn’t free: the application has a cold start, caches are empty, JIT-compiled runtimes need warm-up, and any process that expected to be running 24/7 (cron-driven jobs, queue workers, scheduled health checks against external services) didn’t run during the pause.

The blast radius — the list of things that break when an environment stops — depends on the environment’s role:

  • Pure developer staging. Almost nothing. The blast radius is “the developer notices it’s stopped and clicks start.” Negligible.
  • Staging with overnight CI runs. CI jobs queued at 3am fail because the deploy target doesn’t exist. Mitigation: trigger start-up from the CI pipeline before the deploy step.
  • Staging with cron-driven scheduled jobs. Anything cron-driven inside the environment is suspended. If staging is the canary for production cron logic, you stop testing it overnight. Mitigation: keep one small “cron canary” environment running, separate from the full staging.
  • Customer-facing UAT. If a customer accesses UAT at 11pm on a Friday and the environment is paused, that’s a support incident. Mitigation: tag UAT environments differently and exclude them from the policy.
  • Production. Never on the policy. Production is awake.

The cron pattern itself is dumb-simple. The policy work is figuring out which environments tolerate it, who can override, and what runs during the pause window.

How to verify

List your environments and their last 24h activity. Anything with zero login activity and zero HTTP traffic outside business hours is a candidate.

# 1. List all environments with their tags
curl -s "https://app.paas.example/1.0/environment/control/GetEnvs?session=$SESSION" \
  | jq '.infos[] | {name: .env.shortdomain, status: .env.status, tags: .env.tags}'

# 2. Filter to non-prod by tag (assuming you tag environments)
curl -s "https://app.paas.example/1.0/environment/control/GetEnvs?session=$SESSION" \
  | jq '.infos[] | select(.env.tags[]? | contains("env:staging") or contains("env:dev"))'

# 3. Check HTTP activity for an environment in the last 24h
curl -s "https://app.paas.example/1.0/statistic/main/GetSumStat?session=$SESSION&envName=acme-staging&duration=86400&interval=3600" \
  | jq '.array[] | {hour: .timestamp, requests: .requests}'

For each candidate, scan the inside of the environment for scheduled work:

# Inside the environment - list crontabs for all users
for user in $(getent passwd | cut -d: -f1); do
  echo "=== $user ===" && crontab -u "$user" -l 2>/dev/null
done

# systemd timers
systemctl list-timers --all

# Queue workers / background processes
ps auxf | grep -E '(worker|cron|scheduler|queue)' | grep -v grep

If anything in those lists is critical to the application’s correctness — a daily settlement job, an hourly export to S3, a session-cleanup task — it either moves to a service the stop/start policy doesn’t touch, or you don’t apply the policy to that environment.

The fix

Three-tier policy that handles real environments:

  1. Tag everything. Use environment tags like env:prod, env:staging, env:dev, env:uat. The policy is a function of tags, not names. Names drift; tags survive.

  2. Default policy by tag:

    • env:prod — never stopped
    • env:uat — never stopped (customer-facing), but throttled to smaller cloudlets outside business hours
    • env:staging — stop 8pm-7am weeknights, full weekend pause, manual override available
    • env:dev — stop 7pm-8am, weekend off, plus stop after 4 hours of zero HTTP activity
  3. Implement with the platform’s scheduling API plus an override channel. A small script run from a control plane VM:

#!/usr/bin/env bash
# /opt/sh/shutdown-policy.sh - run from cron on a control plane VM
set -euo pipefail

SESSION="${SH_PAAS_SESSION:?missing}"
API="https://app.paas.example/1.0"
ACTION="${1:-stop}"    # stop | start
TAG="${2:-env:staging}"

# Skip if it's a public holiday (read from a file maintained by ops)
HOLIDAY_FILE=/etc/sh/holidays.txt
TODAY=$(date +%Y-%m-%d)
if grep -qx "$TODAY" "$HOLIDAY_FILE" 2>/dev/null; then
  echo "Skipping - $TODAY is a holiday"
  exit 0
fi

# Skip if any environment with tag has an active override
OVERRIDE_FILE=/etc/sh/shutdown-overrides.txt

# List environments with matching tag
curl -sf "$API/environment/control/GetEnvs?session=$SESSION" \
  | jq -r --arg tag "$TAG" '.infos[] | select(.env.tags[]? == $tag) | .env.shortdomain' \
  | while read -r env; do
      if grep -qx "$env" "$OVERRIDE_FILE" 2>/dev/null; then
        echo "Skipping $env - override active"
        continue
      fi
      echo "==> $ACTION $env"
      curl -sf "$API/environment/control/${ACTION^}Env?session=$SESSION&envName=$env" \
        | jq -r '.result // .error'
    done

Cron entries on the control plane VM:

# Stop staging at 8pm weeknights
0 20 * * 1-5 /opt/sh/shutdown-policy.sh stop env:staging
# Start staging at 7am weekdays
0 7 * * 1-5 /opt/sh/shutdown-policy.sh start env:staging
# Friday 8pm full weekend pause
0 20 * * 5 /opt/sh/shutdown-policy.sh stop env:staging
# Monday 7am wake up
0 7 * * 1 /opt/sh/shutdown-policy.sh start env:staging

The override channel: a slack command or a small /opt/sh/override-env script that appends an environment name to /etc/sh/shutdown-overrides.txt for the next 48 hours, then is auto-cleared. Without an override mechanism, developers will work around the policy by removing tags — and you’ll lose the discipline.

  1. One-time audit before activating. Before the first night of the policy, walk through each environment with the developer who owns it. Ask: “Is there anything that runs after 8pm here?” The answer “I don’t think so” is not good enough. Check the crontabs. Check the queue workers. If anything turns up, either move it to a service the policy doesn’t touch or carve that environment out.

  2. Measure the savings after 30 days. Compare cloudlet-hours billed in the prior month vs the current month for the tagged environments. If the savings are below 30%, the policy isn’t covering enough hours. If something broke twice, the policy is too aggressive.


We design and operate idle-shutdown policies as part of environment management on managed PaaS — tag taxonomy, override channel, blast-radius audit, monthly savings report. If non-prod is running 24/7 and you suspect it shouldn’t be, book a non-prod audit.