Getting Started with CronJS

Welcome to CronJS! This guide will help you get started with creating and managing JavaScript cron jobs in the cloud without any infrastructure management.

What is CronJS?

CronJS is a cloud platform that allows you to run JavaScript cron jobs in secure, isolated Docker containers. Perfect for automation, data processing, API monitoring, and scheduled tasks without the hassle of server management.

Prerequisites

Before you begin, you’ll need:

  • A modern web browser
  • Basic knowledge of JavaScript
  • Understanding of cron syntax (we’ll help you with this!)

Account Registration

Step 1: Visit CronJS

Navigate to https://app.cronjs.com in your web browser.

Step 2: Choose Authentication Method

CronJS uses Firebase Authentication with multiple options:

  1. Email/Password signup - Create an account with your email
  2. Google OAuth - Sign in with your Google account
  3. Additional OAuth providers - Other social logins via Firebase

Step 3: Complete Registration Flow

  1. Click “Sign Up” or “Login” on the homepage
  2. Choose your preferred authentication method (email/password or OAuth)
  3. Complete the Firebase authentication process
  4. Verify your email address (required)
  5. You’ll receive a Firebase ID token automatically
  6. This token is used for all platform authentication

Dashboard Overview

Once logged in, you’ll see the main dashboard:

CronJS Dashboard showing jobs list with create button and job status indicators

Key Features Visible:

  • Jobs list with count - See all your cron jobs at a glance
  • Create Job button - Start creating new jobs
  • Refresh button - Update the jobs list
  • Job table with status indicators - Monitor job health and execution status

Creating Your First Job

Step 1: Start Job Creation

From the dashboard, click the “Create Job” button to begin.

Step 2: Basic Job Information

  1. Fill in the job name - Choose a descriptive name for your job
  2. Choose starting point - Decide if you want to start with a blank job or use a template

Step 3: Write Your JavaScript Code

The job creation interface includes a code editor with:

  • Full JavaScript syntax highlighting
  • IntelliSense and autocomplete
  • Error detection and highlighting
// Example: Simple logging job
console.log("Hello from CronJS!");
console.log("Current time:", new Date().toISOString());

// Example: API call
const response = await fetch("https://api.example.com/status");
const data = await response.json();
console.log("API Status:", data);

Step 4: Add Environment Variables (Optional)

Set secure environment variables for your job:

  1. Navigate to the “Environment Variables” section
  2. Add key-value pairs for sensitive data
  3. Variables are securely stored and encrypted
  4. Once saved, they cannot be viewed but can be overwritten

Access them in your code:

const apiUrl = process.env.API_URL;
const dbPassword = process.env.DATABASE_PASSWORD;
console.log("Connecting to:", apiUrl);

Step 5: Add Dependencies (Optional)

If your job needs external npm packages, add them in the dependencies section.

Step 6: Set Cron Schedule

Choose how often your job should run:

CronJS Visual Cron Builder interface

You have three options:

  1. Pick a preset - Common patterns like “Daily at 9 AM” or “Every 5 minutes”
  2. Use the visual builder - Interactive interface to build complex schedules
  3. Write the cron expression - Direct input for advanced users

Standard cron format (5 fields): minute hour day month day-of-week

Step 7: Configure Resource Limits (Optional)

Default limits for free tier:

  • CPU: 0.25 CPU cores
  • Memory: 128 MB
  • Timeout: 60 seconds

Note: Higher limits available with paid plans

Step 8: Review and Create

  1. Review your job summary
  2. Click “Create Job” to save
  3. Your job is now created and will run according to the schedule

Testing Your Job

Manual Execution

Don’t want to wait for the cron schedule? Test immediately:

  1. Navigate to your job details page
  2. Click the “Run Now” button
  3. Job executes immediately
  4. Execution status shown in real-time
  5. Logs and output displayed in execution history

Viewing Execution Logs

Monitor your job’s performance:

  1. Job Details page shows recent execution history
  2. Each execution displays:
    • Start/end time
    • Exit code (0 = success, non-zero = error)
    • Full console output/logs
    • Error messages (if any)
    • Execution duration

Managing Your Jobs

Enable/Disable Jobs

  1. Go to the job details page
  2. Enter “Edit” mode
  3. Toggle the “Enabled” radio button
  4. Save changes

Job Limitations (MVP)

Current limitations in the MVP version:

  • No API access - Jobs managed via web interface only
  • No bulk operations - Jobs managed individually
  • No job stopping - Jobs run until completion or timeout
  • UI-only management - No programmatic API yet

JavaScript Environment

Your jobs run in a secure, isolated environment:

  • Node.js: Latest LTS version
  • Pre-installed packages: Base system packages
  • Custom packages: Via package.json dependencies
  • File system: Temporary filesystem only (no persistent storage)
  • Network access: Full internet access allowed
  • Isolation: Each job runs in its own Docker container

Common Use Cases

Website Monitoring

const response = await fetch("https://yoursite.com/api/health");
if (!response.ok) {
  console.error("Site is down!");
  // Send alert notification
}

Data Synchronization

// Fetch data from API
const data = await fetch("https://api.source.com/data");
const jsonData = await data.json();

// Process and send to destination
await fetch("https://api.destination.com/import", {
  method: "POST",
  body: JSON.stringify(jsonData),
});

Daily Reports

const today = new Date().toISOString().split("T")[0];
console.log(`Daily Report for ${today}`);

// Generate and send report
const report = await generateDailyReport();
await sendEmailReport(report);

Next Steps

Now that you’ve created your first job:

  1. Monitor execution logs - Learn to debug and optimize
  2. Advanced scheduling patterns - Master complex cron expressions
  3. Environment best practices - Secure your jobs
  4. Troubleshooting guide - Solve common issues

Need Help?

Welcome to the CronJS community! 🚀