Jobs handle the execution of one-time and repeated tasks. Northflank Jobs - just like Services - rely on Docker images that are
- built from the commits of a linked Git repository,
- and executed on the Northflank cloud platform.
There are two types of Jobs:
- Normal Jobs, run manually
- Cron Jobs, scheduled to run repeatedly
In the following sections we cover how to create, manage and delete them.
To create a new Job:
- Navigate to your Project
- Select Job from the Create new drop-down menu in the top right corner of the screen
- Select Normal or Cron as the job type
- Type in a Job Name and a Description
- If you selected the Cron Job type, enter a Schedule. See explanation below.
- Select a Git Provider
- Select the Project Repository and Project Branch
- Specify a Build Context and Dockerfile location if necessary
- Click Verify to verify your Dockerfile
- Select a Plan
- Finish by clicking Create Job
The Cron Job Schedule is a cron expression. It consists of five fields representing the time at which to execute a specified command.
* * * * * | | | | | | | | | |___ day of week (0-6) (Sunday is 0) | | | |_____ month (1-12) | | |_______ day of month (1-31) | |_________ hour (0-23) |___________ minute (0-59)
noteFor simple cron expressions you have option to use the following variables:
You can change different aspects of a Job's configuration, such as schedule, Docker-related variables and scaling.
You can specify the maximum number of attempts to run a job before it is marked as failed.
You can specify (in seconds) the maximum amount of time for a job to run, whether it has failed or not. This will take precedence over the Retry Limit. For example, if you set a Retry Limit of 6, and a Time Limit of 480, the job will be terminated after 8 minutes even if it has only attempted to run 4 times.
You can update the Cron schedule the following way:
- Select the Configuration tab
- Select Job Settings from the menu bar
- Type in the desired Cron expression
- Click Submit
Choose whether to allow this job to run while another instance of the job is running, or to replace the currently running instance.
Allow will enable multiple instances of this job to run. Forbid will keep the current instance of the job running and stop a new instance from being run. Replace will terminate any currently running instance of the job and start a new one.
Start Time Limit
You can choose not to start a job if it fails to start within a specified time limit. You must specify the limit in seconds.
For example, if you set a Retry Limit of 6 and a Time Limit of 480, the job will terminate after 8 minutes regardless of how many times it attempted to run.
Add, edit, or delete Build parameters.
Add, edit, or delete Environment variables.
Choose to make the job free or change the paid plan. Read more about plans.
View the charges associated with the job to inform your decisions on Scaling, or delete the job.
The Continuous Integration and Delivery features within Northflank are also relevant for Jobs. Two settings are responsible for managing their behavior: Build latest and Use latest build.
Build latest is active by default. Every new commit to the linked repository will automatically result in a new build. If Use build latest is activated, new Job runs will automatically use the latest available image.
The toggle controls for switching these behaviors on and off are located in the top right-hand corner of the screen.
You can see all the latest commits, recent builds and Job runs in the Overview tab.
Running a Job
As already mentioned Normal Jobs run once upon creation.
To manually run a Job:
- Click Run (play icon) in the top right side of the screen
- Confirm Run job in the resulting modal
Cron Jobs run automatically as scheduled. They can be suspended using the Job active toggle to the left of the play icon.
Pausing a Job
To pause a Job:
- Click Pause (pause icon) in the top right side of the screen
- Confirm Pause job in the resulting modal
Pausing a job will:
- disable continuous integration and deployment (toggling Build latest and Use latest build),
- and in the case of Cron Jobs suspend scheduled runs (Job active toggle).
Here you can manually create new builds and view the logs of current and past builds.
A list of past
deleted Job runs. Clicking on a run provides access to its logs.
Running jobs can be aborted.