Kamui Platform Kamui Platform Docs
EN JA

Jobs (CronJob)

Jobs are tasks that run periodically on a specified schedule. Use them for batch processing, data aggregation, periodic cleanup, and more.

What is a Job?

  • A program that runs automatically at specified times
  • Uses code from the same repository as your applications
  • Can connect to databases
  • Execution history and logs are available

Creating a Job

  1. In the project detail screen, click "New Job"
  2. Enter basic settings:
Field Description Example
Job Name Identifier name daily-report
Language Programming language to use Node.js / Go / Python
  1. Select deploy source:
Field Description Example
Repository Source code repository myorg/my-jobs
Branch Branch to use main
Directory Subdirectory (for monorepos) jobs/report
  1. Execution settings:
Field Description Example
Command Command to execute node report.js
Setup Command Install dependencies npm install
Pre Command Pre-processing command npm run build
  1. Schedule settings:
Field Description
Schedule Type Preset or custom
Cron Expression Only for custom type
  1. Optional settings:
  2. Spec (resource size)
  3. Environment variables
  4. Database connection

  5. Click "Create"

Schedule Types

Presets

Type Timing Cron Expression
Hourly Every hour at :00 0 * * * *
Daily (Midnight) Daily at 0:00 0 0 * * *
Daily (3 AM) Daily at 3:00 0 3 * * *
Daily (9 AM) Daily at 9:00 0 9 * * *
Weekly (Sunday) Sundays at 0:00 0 0 * * 0
Weekly (Monday) Mondays at 0:00 0 0 * * 1
Monthly (1st) 1st of month at 0:00 0 0 1 * *

Custom (Cron Expression)

Specify using standard cron expression format.

┌───────── minute (0 - 59)
│ ┌───────── hour (0 - 23)
│ │ ┌───────── day of month (1 - 31)
│ │ │ ┌───────── month (1 - 12)
│ │ │ │ ┌───────── day of week (0 - 6, 0 = Sunday)
│ │ │ │ │
* * * * *

Examples:

Cron Expression Meaning
*/15 * * * * Every 15 minutes
0 */2 * * * Every 2 hours
30 8 * * 1-5 Weekdays at 8:30
0 0 15 * * 15th of each month at 0:00

Note: Timezone is UTC. Japan Standard Time (JST) is UTC+9.

Running a Job Immediately

To run a job now without waiting for the schedule:

  1. Open the job detail screen
  2. Click the "Run Now" button
  3. Click "Execute" in the confirmation dialog

Viewing Execution History

  1. Click the "Execution History" tab in the job detail screen
  2. View information for each execution:
  3. Start time
  4. End time
  5. Duration
  6. Status (success / failure)

Viewing Execution Logs

  1. Select an execution from the history
  2. View stdout / stderr output in the log screen

Editing a Job

  1. Click the "Settings" tab in the job detail screen
  2. Editable fields:
  3. Schedule
  4. Command
  5. Spec
  6. Environment variables
  7. Database connection
  8. Click "Save"

Pausing a Job

To temporarily stop scheduled execution:

  1. Click "Pause" in the job detail screen
  2. The job will no longer run on schedule
  3. Click "Resume" to restart scheduled execution

Deleting a Job

  1. Click the "Settings" tab in the job detail screen
  2. Click "Delete Job"
  3. Enter the job name in the confirmation dialog
  4. Click "Delete"

⚠️ Warning: Execution history will also be deleted. This action cannot be undone.

Use Case Examples

Daily Report Generation

// report.js
const { Pool } = require('pg');

async function generateReport() {
  const pool = new Pool({ connectionString: process.env.DATABASE_URL });

  const result = await pool.query(`
    SELECT DATE(created_at) as date, COUNT(*) as count
    FROM orders
    WHERE created_at >= NOW() - INTERVAL '1 day'
    GROUP BY DATE(created_at)
  `);

  console.log('Daily Report:', result.rows);
  // Send email or Slack notification
}

generateReport().catch(console.error);

Data Cleanup

# cleanup.py
import os
import psycopg2
from datetime import datetime, timedelta

conn = psycopg2.connect(os.environ['DATABASE_URL'])
cursor = conn.cursor()

# Delete temporary data older than 30 days
cursor.execute("""
    DELETE FROM temp_data
    WHERE created_at < NOW() - INTERVAL '30 days'
""")

conn.commit()
print(f"Deleted {cursor.rowcount} old records")

Next Steps