<!--
hoody-cron Subskill (http)
Auto-generated by Hoody Skills Generator
Generated: 2026-05-06T18:32:03.369Z
Model: mimo-v2.5-pro + fixer:z-ai/glm-5.1
Mode: http


Tokens: 4735

DO NOT EDIT MANUALLY - Changes will be overwritten on next generation
-->

# hoody-cron Subskill

## Overview

**hoody-cron** provides managed cron job scheduling for Hoody containers. It enables you to create, schedule, enable/disable, and auto-expire recurring tasks within your Hoody project.

### When to Use

- **Scheduled Tasks**: Run commands on a recurring schedule (daily reports, cleanup jobs, backups)
- **One-time Delayed Execution**: Schedule a task for a specific future time
- **User-scoped Jobs**: Each user maintains their own crontab and entries
- **Auto-expiration**: Jobs can be configured to expire automatically

### Service Philosophy

hoody-cron follows Hoody's managed services philosophy: you define *what* and *when*, the platform handles execution, monitoring, and lifecycle management. No need to manage cron daemons, log rotation, or process supervision.

### Architecture

- **Per-user isolation**: Each user has their own crontab and entry set
- **REST API**: Full CRUD operations on cron entries
- **Standard cron syntax**: Uses familiar cron scheduling expressions
- **Container-native**: Runs within your Hoody container infrastructure

### Base URL

```
https://{projectId}-{containerId}-cron-{serviceId}.{node}.containers.hoody.icu
```

Replace placeholders with your actual Hoody project values. See the core SKILL.md for container creation and service discovery.

---

## Common Workflows

### Workflow 1: Health Check

Verify the cron service is running and responsive.

```
curl -s "https://{projectId}-{containerId}-cron-{serviceId}.{node}.containers.hoody.icu/health"
```

Expected response:

```
{
  "status": "ok"
}
```

### Workflow 2: Create a Scheduled Entry

Create a new cron job for a user.

**Step 1**: Create the entry with command and schedule.

```
curl -s -X POST "https://{projectId}-{containerId}-cron-{serviceId}.{node}.containers.hoody.icu/users/myuser/entries" \
  -H "Content-Type: application/json" \
  -d '{
  "command": "/usr/bin/backup.sh",
  "schedule": "0 2 * * *"
}'
```

Expected response:

```
{
  "id": "entry-abc123",
  "command": "/usr/bin/backup.sh",
  "schedule": "0 2 * * *",
  "enabled": true
}
```

**Step 2**: Verify the entry was created.

```
curl -s "https://{projectId}-{containerId}-cron-{serviceId}.{node}.containers.hoody.icu/users/myuser/entries/entry-abc123"
```

### Workflow 3: List All Entries for a User

Retrieve all cron entries for a specific user.

```
curl -s "https://{projectId}-{containerId}-cron-{serviceId}.{node}.containers.hoody.icu/users/myuser/entries"
```

Expected response:

```
[
  {
    "id": "entry-abc123",
    "command": "/usr/bin/backup.sh",
    "schedule": "0 2 * * *",
    "enabled": true
  },
  {
    "id": "entry-def456",
    "command": "/usr/bin/cleanup.sh",
    "schedule": "30 3 * * 0",
    "enabled": true
  }
]
```

### Workflow 4: Update an Existing Entry

Modify the schedule or command of an existing cron entry.

```
curl -s -X PATCH "https://{projectId}-{containerId}-cron-{serviceId}.{node}.containers.hoody.icu/users/myuser/entries/entry-abc123" \
  -H "Content-Type: application/json" \
  -d '{
  "schedule": "0 4 * * *"
}'
```

**Verification**: Fetch the entry to confirm changes applied.

```
curl -s "https://{projectId}-{containerId}-cron-{serviceId}.{node}.containers.hoody.icu/users/myuser/entries/entry-abc123"
```

### Workflow 5: Delete an Entry

Remove a cron entry that is no longer needed.

```
curl -s -X DELETE "https://{projectId}-{containerId}-cron-{serviceId}.{node}.containers.hoody.icu/users/myuser/entries/entry-abc123"
```

**Verification**: Confirm deletion by listing entries.

```
curl -s "https://{projectId}-{containerId}-cron-{serviceId}.{node}.containers.hoody.icu/users/myuser/entries"
```

### Workflow 6: Replace Entire Crontab

Replace a user's full crontab configuration in one operation.

**Step 1**: Get current crontab for reference.

```
curl -s "https://{projectId}-{containerId}-cron-{serviceId}.{node}.containers.hoody.icu/users/myuser/crontab"
```

**Step 2**: Replace with new crontab.

```
curl -s -X PUT "https://{projectId}-{containerId}-cron-{serviceId}.{node}.containers.hoody.icu/users/myuser/crontab" \
  -H "Content-Type: application/json" \
  -d '{
  "crontab": "0 2 * * * /usr/bin/backup.sh\n0 3 * * 0 /usr/bin/cleanup.sh"
}'
```

**Step 3**: Verify the new crontab.

```
curl -s "https://{projectId}-{containerId}-cron-{serviceId}.{node}.containers.hoody.icu/users/myuser/crontab"
```

---

## Advanced Operations

### Multi-User Job Management

Manage cron jobs across multiple users in a project.

**Step 1**: List all crontabs across all users.

```
curl -s "https://{projectId}-{containerId}-cron-{serviceId}.{node}.containers.hoody.icu/crontab"
```

**Step 2**: Create entries for each user as needed.

```
curl -s -X POST "https://{projectId}-{containerId}-cron-{serviceId}.{node}.containers.hoody.icu/users/alice/entries" \
  -H "Content-Type: application/json" \
  -d '{
  "command": "/usr/bin/report.sh --user alice",
  "schedule": "0 8 * * 1-5"
}'
```

```
curl -s -X POST "https://{projectId}-{containerId}-cron-{serviceId}.{node}.containers.hoody.icu/users/bob/entries" \
  -H "Content-Type: application/json" \
  -d '{
  "command": "/usr/bin/sync.sh --user bob",
  "schedule": "*/15 * * * *"
}'
```

### Error Recovery: Recreate Failed Entry

If an entry becomes corrupted or needs replacement:

**Step 1**: Delete the problematic entry.

```
curl -s -X DELETE "https://{projectId}-{containerId}-cron-{serviceId}.{node}.containers.hoody.icu/users/myuser/entries/entry-bad123"
```

**Step 2**: Create a fresh entry with corrected configuration.

```
curl -s -X POST "https://{projectId}-{containerId}-cron-{serviceId}.{node}.containers.hoody.icu/users/myuser/entries" \
  -H "Content-Type: application/json" \
  -d '{
  "command": "/usr/bin/fixed-script.sh",
  "schedule": "0 */6 * * *"
}'
```

**Step 3**: Verify the new entry is active.

```
curl -s "https://{projectId}-{containerId}-cron-{serviceId}.{node}.containers.hoody.icu/users/myuser/entries"
```

### Bulk Crontab Migration

Migrate a user's entire crontab to a new configuration:

**Step 1**: Export current state.

```
curl -s "https://{projectId}-{containerId}-cron-{serviceId}.{node}.containers.hoody.icu/users/myuser/crontab"
```

**Step 2**: Apply new crontab.

```
curl -s -X PUT "https://{projectId}-{containerId}-cron-{serviceId}.{node}.containers.hoody.icu/users/myuser/crontab" \
  -H "Content-Type: application/json" \
  -d '{
  "crontab": "0 1 * * * /usr/bin/new-backup.sh\n0 5 * * 0 /usr/bin/weekly-report.sh\n*/30 * * * * /usr/bin/health-check.sh"
}'
```

### Performance Considerations

- **Batch reads**: Use `GET /users/{user}/entries` instead of fetching entries individually
- **Crontab vs entries**: Use `PUT /users/{user}/crontab` for bulk updates rather than multiple individual `POST` calls
- **Rate limiting**: Space out bulk operations to avoid overwhelming the service
- **Schedule precision**: Cron entries execute at minute granularity; sub-minute scheduling is not supported

### OpenAPI Specification Access

Retrieve the service's API specification for integration tooling:

```
curl -s "https://{projectId}-{containerId}-cron-{serviceId}.{node}.containers.hoody.icu/openapi.json"
```

```
curl -s "https://{projectId}-{containerId}-cron-{serviceId}.{node}.containers.hoody.icu/openapi.yaml"
```

---

## Quick Reference

### Required Parameters

- **`user`** (path): Username identifier for all user-scoped endpoints
- **`id`** (path): Entry identifier for entry-specific operations

### Common Cron Schedules

| Expression | Meaning |
|------------|---------|
| `0 2 * * *` | Daily at 2:00 AM |
| `*/15 * * * *` | Every 15 minutes |
| `0 0 * * 0` | Weekly on Sunday midnight |
| `0 9 * * 1-5` | Weekdays at 9:00 AM |
| `0 0 1 * *` | First day of each month |