Claude Tips mascot
Claude Tips & Tricks
Claude Code advanced

Schedule Claude Tasks That Survive Restarts

Use cron jobs or GitHub Actions schedules for Claude Code tasks that need to run on a timer, even when your terminal is closed.

/loop is great but dies when you close the terminal. For persistent scheduling, use system-level tools.

Cron + Headless Mode

# Edit crontab
crontab -e

# Run a code review every morning at 9am
0 9 * * * cd /path/to/project && claude -p "Review any PRs opened in the last 24 hours. Post comments on GitHub." --allowedTools "Read,Bash(gh *)" >> /tmp/claude-review.log 2>&1

# Check for dependency updates weekly
0 10 * * 1 cd /path/to/project && claude -p "Run npm audit and npm outdated. Summarize what needs updating." >> /tmp/claude-deps.log 2>&1

GitHub Actions Schedule

name: Weekly Code Health
on:
  schedule:
    - cron: '0 9 * * 1'  # Monday 9am UTC

jobs:
  health-check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
          prompt: |
            Run the test suite and linter.
            If anything fails, create a GitHub issue with the details.

When to Use What

NeedTool
Quick check while working/loop
Daily/weekly automationCron + headless
Team-wide scheduled tasksGitHub Actions
One-time delayed task/loop or at command

Tip

Add jitter to cron schedules. Instead of 0 9 * * *, use 3 9 * * * to avoid rate limits if multiple repos trigger at the same time.