Deployment of manual and scheduled jobs

Cron Jobs

A job is a task designed to execute background work and computation on a cron schedule or event invocation through manual trigger, API request, webhook or 3rd party integration.

Scheduled Jobs

Easily link Northflank with GitHub, Bitbucket, or GitLab (both gitlab.com and self-hosted) and run your code on a schedule. A job can build and run any code with a Dockerfile, Buildpack — or use an existing Docker image from a public or private repository. Northflank completely automates your jobs, including logs and metrics in a container based deployment.

As things start to scale, select from a range of plans starting at $2.70 per month.

Need to deploy jobs on your Kubernetes cluster? Click here.

Cron Jobs on Northflank

CI/CD

With active CI every new commit to the linked repository will result in a new build and with active CD new job runs will automatically use the latest available build.

Retry logic

Set up a retry logic for cron jobs, so after a failed build it will retry several times before it is marked as failed.

Observe and Monitor

Observe your jobs and background workers in real-time with log tailing, search and performance metrics.

Multiple concurrent runs

Run multiple jobs in parallel at the same time, triggered via cron schedule or API trigger.

Cron schedule

Schedule jobs using a cron expression, specifying at which times to execute a specified command.

Manual Trigger

Create a manual job to run once whenever you trigger it.

API Access

Create and reschedule jobs through our API.

Secret injection and databases

Connect jobs to databses and stateful workloads on Northflank or 3rd party services with injected secrets.

Job timeouts

A time limit will set the maximum amount of time a job can run, whether it has failed or not.

Deploy external Docker images

Choose an external Docker image for deployment in jobs so you can run any pre-built image.

Run jobs in pipelines

Use jobs in pipelines for complex workloads, for example migrations or workers to trigger during release.

Jobs on Northflank dashboard

Cron Jobs use cases

  • Automating system maintenance
  • Update summary tables, for example daily traffic summaries
  • Expire and erase cached data files in a certain interval
  • Schedule long-running tasks to run from a command line script, for example encoding videos

Schedule

* * * * *
| | | | |
| | | | |_ day of week (0-6, 0 is Sunday)
| | | |___ month (1-12)
| | |_____ day of month (1-31)
| |_______ hour (0-23)
|_________ minute (0-59)

For example:

  • 30 23 27 1 * will execute at 23:30 on January 27th.
  • 30 23 * * 0 will execute every Sunday.

You can also use @yearly, @annually, @monthly, @weekly, @daily, or @hourly.

Platform Teams

Northflank makes it easier for infrastructure and platform teams to focus on levelling up the developer experience for their teams building great apps.

Common Cron Jobs questions among developers and platform teams:

How to set up a cron job?

Within a project, navigate to Jobs and create a job.

How to check if cron job is running?

Once a cron job has been created, the section “Recent Job Runs” will provide details of the status of all the jobs that ran or failed.

How to run a cron job manually?

You can choose to create a manual job. This will add the job to the pipeline but it won’t run until you click the Rub Job button.

How to schedule a cron job to run every hour?

Using the tag @hourly, the cron job will run every hour.

How to change the schedule of a cron job?

Under settings, the schedule for the job can be changed.

How to set up health checks for a cron job?

Health checks can be configured so that incoming traffic is only routed to available and healthy containers. Under health checks, you can configure the type, path, protocol and frequency with which the checks will run.

How to increase the resources for a cron job?

Once the cron job is created, under resources you can change the compute plan (memory and virtual CPU) to adapt to your needs.

Jobs and Cron Jobs on Kubernetes with Northflank

Northflank makes building scalable async job queues, background workers and event-based computation very simple.

The complex and challenging Kubernetes Job spec is immediately useable via the Northflank UI and API.

Immediately set up CI/CD flows, schedule workloads, and set up sensible retry, timeout, and parallel run options.


Run a job with a Docker CMD Override and image from DockerHub

await apiClient.start.job.run({
  parameters: {
    ...
  },
  data: {
    runtimeEnvironment: {
      "VARIABLE_1": "abcdef",
      "VARIABLE_2": "12345"
    },
    deployment: {
      cmdOverride: "date",
      external: {
        imagePath: "alpine:latest"
      }
    }
  }    
});

Build and run a Git repository on a cron schedule

await apiClient.create.job.cron({
  data: {
    "backoffLimit": 0,
    "runOnSourceChange": "never",
    "activeDeadlineSeconds": 600,
    "deployment": {
      "cmdOverride": "nginx -g",
      "vcs": {
        "projectUrl": "https://github.com/northflank/gatsby-with-northflank",
        "projectType": "github",
        "accountLogin": "github-user",
        "projectBranch": "master"
      }
    },
    "buildSettings": {
      "dockerfile": {
        "buildEngine": "kaniko",
        "useCache": false,
        "dockerFilePath": "/Dockerfile",
        "dockerWorkDir": "/"
      }
    },
    "schedule": "30 8 * * *",
    "concurrencyPolicy": "forbid"
  }    
});

Jobs creation on Northflank dashboard

Other related Cron Jobs and Northflank content