Loading...
Loading...
Create an OpenClaw cron job that sends a message to the specified channel after execution. Use this skill when the user mentions phrases like "create scheduled task", "new cron", "set scheduled execution", "run periodically", "scheduled task", "every", "every minute", "every hour", "every week", "every month", or "every X hours between A and B". Collect the task name, task description, and execution time (supports four modes: fixed time, interval loop, periodic time, and scheduled range) through conversation, automatically obtain the session key (no user cooperation required), then construct and execute the openclaw cron add command.
npx skill4agent add rinsonlaw/law-skills build-cronopenclaw cron addnpx skills add https://github.com/Rinsonlaw/law-skills.gitdaily-report--messageAutomatic Session Key Retrieval: Automatically obtained from the current session's metadata; no manual input required from the user.
:session_key = "agent:research:feishu:direct:ou_xxx"
agent_id = session_key_parts[1] # → "research"
channel_name = session_key_parts[2] # → "feishu"
target_id = session_key_parts[4] # → "ou_xxx"| Position | Meaning | Value Range |
|---|---|---|
| 1st | Minute | 0-59, |
| 2nd | Hour | 0-23, |
| 3rd | Day of Month | 1-31 |
| 4th | Month | 1-12 |
| 5th | Day of Week | 0-6 (0=Sunday) |
*AA-B10-125-312-5*/N*/5A-B/N10-12/1"*/5 * * * *"*/5"0 */2 * * *"*/2"0 * * * *""0 9 * * 1""0 0 1 * *""0 10-12/1 * * *""0 9-18/2 * * 1-5"{minute} {hour} * * *"0 8 * * *"*/{interval} * * * *0 */{interval} * * *{minute} {hour} {day_of_month} {month} {day_of_week}"0 9 * * 1""0 0 1 * *"{minute} {start_hour}-{end_hour}/{interval} * * *"0 10-12/1 * * *""0 9-18/2 * * *"openclaw cron addTZ=$(readlink /etc/localtime | sed 's|.*zoneinfo/||')
openclaw cron add \
--name "{task_name}" \
--agent "{agent_id}" \
--session-key "{session_key}" \
--cron "{cron_expr}" \
--tz "$TZ" \
--session "isolated" \
--wake "now" \
--message "{task_message}" \
--timeout-seconds 600 \
--announce \
--channel "{channel_name}" \
--to "{target_id}"| CLI Parameter | Description | Default Value |
|---|---|---|
| Task name | Required |
| Parsed from sessionKey | Required |
| Complete session key | Required |
| Cron expression | Required |
| Time zone | Automatically detected via |
| Session mode | |
| Wake-up mode | |
| Task description (user's exact words, no modifications) | Required |
| Timeout in seconds | |
| Enable result announcement to channel | Disabled by default |
| Announcement channel | Parsed from sessionKey |
| Announcement target | Parsed from sessionKey |
Note: The time zone is fixed to; users can replace it if other time zones are needed."Asia/Shanghai"
yesUser: I want to create a scheduled task that runs every day at 8 PM
Assistant: What is the name of this task?
User: nightly-digest
Assistant: What does this task specifically do? (Please provide the exact words to fill into message)
User: Compile and summarize the day's competitor dynamics every night
Assistant: What is the execution time in hour and minute? (e.g., 20 30 means 8:30 PM)
User: 20 30
Assistant: (Automatically retrieves current session key)
Identified as Fixed Time mode, constructed the following command. Please confirm creation:
TZ=$(readlink /etc/localtime | sed 's|.*zoneinfo/||')
openclaw cron add \
--name "nightly-digest" \
--agent "research" \
--session-key "agent:research:feishu:direct:ou_xxx" \
--cron "30 20 * * *" \
--tz "$TZ" \
--session "isolated" \
--wake "now" \
--message "Compile and summarize the day's competitor dynamics every night" \
--timeout-seconds 600 \
--announce \
--channel "feishu" \
--to "ou_xxx"
Confirm creation? (Enter yes to confirm)
User: yes
Assistant: Executing command...User: I want to check server status every 5 minutes
Assistant: What is the name of this task?
User: server-health-check
Assistant: What does this task specifically do? (Please provide the exact words to fill into message)
User: Check if the server status is normal
Assistant: What is the execution time pattern? (e.g., "every 5 minutes" or "every 2 hours")
User: every 5 minutes
Assistant: (Automatically retrieves current session key)
Identified as Interval Loop mode (every 5 minutes), constructed the following command. Please confirm creation:
TZ=$(readlink /etc/localtime | sed 's|.*zoneinfo/||')
openclaw cron add \
--name "server-health-check" \
--agent "research" \
--session-key "agent:research:feishu:direct:ou_xxx" \
--cron "*/5 * * * *" \
--tz "$TZ" \
--session "isolated" \
--wake "now" \
--message "Check if the server status is normal" \
--timeout-seconds 600 \
--announce \
--channel "feishu" \
--to "ou_xxx"
Confirm creation? (Enter yes to confirm)
User: yes
Assistant: Executing command...