Scheduled Tasks and Cron Jobs
Back to Reference
PicoClaw stores scheduled jobs in the current workspace and can run them either as reminders, full agent turns, or shell commands.
Schedule Types
PicoClaw currently uses three schedule forms in the cron tool:
at_seconds: one-time job, relative to now. After it runs, the job is removed from the store.every_seconds: recurring interval, in seconds.cron_expr: recurring cron expression such as0 9 * * *.
cron_expr is evaluated in the time zone of the PicoClaw process, which is set
by the TZ environment variable (for example TZ=Europe/Rome). When TZ is
unset, the system time zone is used, which is usually UTC in containers and on
servers, so 0 9 * * * would fire at 09:00 UTC. Set TZ before starting the
gateway; changing it requires a restart. There is no per-job time zone in the
agent tool or the CLI.
A per-job time zone can be set by editing <workspace>/cron/jobs.json directly.
Add a tz field to the job's schedule object using an IANA location name
(validated with time.LoadLocation):
{
"schedule": {
"kind": "cron_expr",
"expr": "0 9 * * *",
"tz": "America/New_York"
}
}
When tz is set on a job, that job's expression is evaluated in the specified
zone regardless of the process TZ setting. An invalid location name is logged
and the job is skipped on its next tick.
The agent sees the current date and the active zone in the Current Date line
of its prompt, for example Thursday, October 15, 2026 (Europe/Rome, CEST, UTC+02:00). The zone name is taken from TZ; when TZ is unset the name is
omitted and a warning is logged. The time of day is left out on purpose, so the
system prompt stays identical all day and LLM prompt caches keep hitting; the
agent has to look it up (for example with date through the exec tool) when it
needs it.
The CLI command picoclaw cron add currently supports recurring jobs only:
--every <seconds>--cron '<expr>'
There is no CLI flag for a one-time at job today.
Examples:
picoclaw cron add --name "Daily summary" --message "Summarize today's logs" --cron "0 18 * * *"
picoclaw cron add --name "Ping" --message "heartbeat" --every 300
Agent Tool Actions
The agent-facing cron tool supports these actions:
add: create a new job.list: show accessible job names, ids, and schedules, with the last and next run as ISO 8601 timestamps when known.get: fetch one accessible persisted job byjob_id, including its saved payload and derived ISO 8601 local times.update: partially update one accessible job byjob_id; omitted fields are preserved.run: execute one accessible job right now byjob_id, without waiting for its schedule.remove,enable,disable: existing management actions.
list renders run times as ISO 8601 (RFC 3339) timestamps with the process
time zone's UTC offset (the same zone used to evaluate cron expressions), for
example 2026-10-19T09:00:00+02:00; get and update return the raw job JSON —
epoch fields state.nextRunAtMs and state.lastRunAtMs included — together
with a derived localTimes object (lastRun, nextRun) in that same format.
Rendered times are informational; scheduling and storage always use the raw
epoch fields.
When rescheduling an existing task, use list -> get -> update. Do not use
remove -> add just to change the schedule, because recreating a job can drop
the original prompt, delivery target, or command payload.
Remote channel access is scoped to the current channel/chat_id: remote callers
can only act on jobs whose saved payload.channel and payload.to match the
current conversation. This applies to list, get, update, run, remove,
enable, and disable. Single-owner channels are the exception: the Pico WebUI
is authenticated with one shared token and always sends as the fixed pico-user
sender, so its jobs are scoped to the whole channel — a job created in one WebUI
conversation remains visible and manageable from every other one. Because all of
its chats belong to the same owner, this does not widen access to anyone else.
Command jobs include a shell command payload, so they can only be listed,
inspected, updated, or run from internal channels or remote channels allowed by
tools.cron.command_allowed_remotes; that command gate applies on single-owner
channels as well.
Example tool calls:
{"action":"get","job_id":"79095b2f5685a0f2"}
{"action":"update","job_id":"79095b2f5685a0f2","cron_expr":"30 10 * * *"}
update accepts name, message, command, and exactly one schedule field
(at_seconds, every_seconds, or cron_expr).
Omit command to preserve it, set command to a non-empty string to replace
it, or set command to "" to clear it. Setting or replacing a command
requires the same channel allowlist and confirmation gates as command
creation; clearing it does not.
Running a job on demand
The agent tool's run action starts a job immediately and returns without
waiting for it to finish; output is delivered to the job's own channel, exactly
like a scheduled run.
- The schedule is not changed: an
every/cronjob keeps its next run time. A one-timeatjob is consumed like after any run (deleted, or disabled whendeleteAfterRunis false). - Disabled jobs can be run; they stay disabled.
- A job never runs concurrently with itself. If a manual
runfinds the job already executing, it fails withjob is already running. If the scheduler finds the job due while a run is in flight, it skips that occurrence and advances the schedule. Whichever side claims the job first wins. This also means a recurring job whose run is slower than its interval no longer overlaps itself: the occurrences that fall during the run are skipped.
{"action":"run","job_id":"79095b2f5685a0f2"}
Execution Modes
Jobs are stored with a message payload. When a job fires, PicoClaw picks one of two execution paths based on the payload.
command
When a cron-tool job includes command, PicoClaw runs that shell command through the exec tool and publishes the command output directly to the job's channel and recipient. The saved message becomes descriptive text only; the scheduled action is the shell command. Command jobs do not go through the agent.
The current CLI picoclaw cron add command does not expose a command flag.
Agent turn
Without a command, PicoClaw sends the saved message through the agent loop as a new agent turn. Use this for scheduled work that may need reasoning, tools, or a generated reply. This is the default for the cron tool.
A turn started by a cron job receives a tool registry without cron, so the agent cannot call it to manage jobs. This also applies to subagents spawned by that turn.
Config and Security Gates
tools.cron
tools.cron.enabled controls whether the agent-facing cron tool is registered. Default: true.
If you disable tools.cron, users can no longer create or manage jobs through the agent tool. The gateway still starts CronService, but it does not install the job execution callback. As a result, due jobs do not actually run; one-time jobs may be deleted and recurring jobs may be rescheduled without executing their payload. Jobs that fire without a callback are recorded with state.lastStatus: "skipped". The CLI still uses the same job store.
tools.cron.exec_timeout_minutes sets the timeout used for scheduled command execution. Default: 5. Set 0 for no timeout.
tools.exec
Scheduled command jobs depend on tools.exec.enabled. Default: true.
If tools.exec.enabled is false:
- new command jobs are rejected by the cron tool
- existing command jobs publish a
command execution is disablederror when they fire
tools.exec.allow_remote controls direct exec calls from remote channels. It is
independent from the cron command gate: scheduled command jobs are authorized by
tools.cron.command_allowed_remotes and do not require allow_remote. PicoClaw
re-checks that allowlist when a job fires, so removing a channel from the list
also stops already-scheduled jobs from that channel. In practice, reminder jobs
can be scheduled from every channel, while scheduled command jobs are limited to
internal channels and remote channels listed in command_allowed_remotes.
allow_command
tools.cron.allow_command defaults to true.
This is not a hard disable switch. If you set allow_command to false, PicoClaw still allows a command job when the caller explicitly passes command_confirm: true.
Command jobs also require either an internal channel or a remote channel allowed by tools.cron.command_allowed_remotes. That gate is independent of tools.exec.allow_remote, which controls direct exec calls. Non-command reminders do not have that restriction.
command_allowed_remotes
tools.cron.command_allowed_remotes defaults to an empty list. With the default empty list, remote channels cannot schedule command jobs.
Entries can be either a channel name or a channel plus chat id:
telegramallows command jobs from any Telegram chat.telegram:1234567890allows command jobs only from that exact Telegram chat id.*allows command jobs from every non-empty channel.
Warning: * is potentially dangerous because any remote channel that can talk
to PicoClaw can schedule shell commands. Use it only when every enabled remote
channel and chat is trusted to request command execution.
This setting only controls the cron command channel gate. It is independent of
tools.exec.allow_remote: remote command jobs do not need allow_remote, and
enabling allow_remote does not widen this allowlist. The gate does not bypass
tools.cron.allow_command, command_confirm, tools.exec.enabled, or the exec
tool's command safety checks (deny patterns, hardline rules, and risk checks).
Example:
{
"tools": {
"cron": {
"enabled": true,
"exec_timeout_minutes": 5,
"allow_command": true,
"command_allowed_remotes": [
"telegram:1234567890"
]
},
"exec": {
"enabled": true
}
}
}
allow_remote is omitted here: this example allows Telegram command jobs through
the cron allowlist while direct exec from Telegram remains blocked.
Persistence and Location
Cron jobs are stored in:
<workspace>/cron/jobs.json
By default, the workspace is:
~/.picoclaw/workspace
If PICOCLAW_HOME is set, the default workspace becomes:
$PICOCLAW_HOME/workspace
Both the gateway and picoclaw cron CLI subcommands use the same cron/jobs.json file.
The running gateway watches this file (a stat every 2 seconds, scaled up in low-power mode). Hand edits and picoclaw cron add/remove/enable/disable take effect without a restart:
- the file replaces the in-memory job list; jobs whose schedule and enabled flag are unchanged keep their next run time, all others are rescheduled
- an invalid JSON file is logged once and ignored; the gateway keeps its current jobs until the next valid edit
- a deleted file is ignored; the gateway keeps its jobs and recreates the file on the next change
- a job removed from the file while it is running finishes, but is not written back
- one-time jobs already in the past are dropped or disabled, same as at startup
Notes:
- one-time
at_secondsjobs are deleted after they run - one-time jobs whose scheduled time elapsed while the gateway was down are dropped on the next startup (or disabled when they are not marked for deletion), instead of lingering as enabled jobs that never fire
- recurring jobs stay in the store until removed
- disabled jobs stay in the store and still appear in
picoclaw cron list - each run records its outcome in the job state:
state.lastStatusis"ok"on success,"error"with the reason instate.lastErrorwhen the agent turn failed or a scheduled command was disabled or failed, and"skipped"when no execution callback is installed (seetools.cron)