Home/Q&A/Can I schedule Claude Code to run unattended (headless) on a remote Mac mini?

Can I schedule Claude Code to run unattended (headless) on a remote Mac mini?

Updated · airankrush

Direct answer

Yes. Use the non-interactive claude -p mode with cron or launchd to run on a schedule. Whether the machine returns to a runnable state by itself after a reboot is something to have support check against your delivery configuration first.

Basis

  • The non-interactive mode is described in the official docs: claude -p "task description" exits when it finishes, --allowedTools limits which tools it may use, and the output can be redirected to a log file.
  • A machine that stays on, without shutting down or sleeping, is the precondition for scheduled jobs. Your account is an admin account, so you can write your own user-level launchd configuration or crontab.
  • A scheduled job gets fewer environment variables than an interactive terminal; the usual failure is that claude or node cannot be found. Use full paths in the script, or set PATH explicitly at the top.
  • The sign-in credentials are stored under this user. A scheduled job can only read them if it runs as that same user, while that user is logged in.

Information as of .

Boundaries: when the answer is different

Reboots are the biggest unknown here. If the system stops at the login screen after a restart, user-level scheduled jobs do not run and the credentials cannot be read. Automatic login and start-at-login are part of the delivery configuration; ask support to check item by item whether they apply to your machine, and do not follow online tutorials that turn off disk encryption or remove the password. Unattended also means nobody is there to click approve: fix the permission scope in advance, and prefer a job that fails for lack of permission over one given unrestricted permissions. Scheduled jobs draw on the same account's usage, so running them too often eats into your daytime allowance.

How to do it

  1. First get that claude -p command working by hand in a terminal, and note the tool permissions it needs.
  2. Put the command in a script that sets PATH at the top, does a cd into the project directory and appends output to a dated log.
  3. Register the script with crontab -e or a user-level launchd configuration.
  4. Set the trigger a few minutes ahead for a trial run, and check the log for path or sign-in errors.
  5. Send your reboot-recovery requirement to support for assessment; until it is confirmed, plan on "needs a manual check after a reboot".

Use case

This question belongs to the use case: Remote Mac mini for heavy Claude Code use: an always-on workstation, not account insurance

Other questions in the same use case:

Pricing and availability: see the plans page · Help center (中文) · Refund policy (中文) · Telegram Contact support

Back to home · All Q&A