Laravel Forge JavaScript SDK

Scheduled Jobs

Scheduled Jobs

Create a job

Method

forge.jobs.create(server_id, payload)

Usage

1const forge = new Forge('API_TOKEN');
2
3const job = await forge.jobs.create(server_id, payload);

Payload

1{
2 command: 'COMMAND_THE_JOB_RUNS',
3 frequency: 'custom',
4 user: 'root',
5 minute: '*',
6 hour: '*',
7 day: '*',
8 month: '*',
9 weekday: '*'
10}

Payload Parameters

KeyDescription
commandThe command to run.
frequencyThe frequency in which the job should run. Valid values are minutely, hourly, nightly, weekly, monthly, reboot, and custom.
userThe server user to run the command as.
minuteRequired if the frequency is custom.
hourRequired if the frequency is custom.
dayRequired if the frequency is custom.
monthRequired if the frequency is custom.
weekdayRequired if the frequency is custom.

Example Response

1{
2 "job": {
3 "id": 2,
4 "command": "COMMAND_THE_JOB_RUNS",
5 "user": "root",
6 "frequency": "Nightly",
7 "cron": "0 0 * * *",
8 "status": "installing",
9 "created_at": "2016-12-16 15:56:59"
10 }
11}

List jobs

Method

forge.jobs.list(server_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3const jobs = await forge.jobs.list(server_id);

Example Response

1{
2 "jobs": [
3 {
4 "id": 2,
5 "command": "COMMAND_THE_JOB_RUNS",
6 "user": "root",
7 "frequency": "nightly",
8 "cron": "0 0 * * *",
9 "status": "installing",
10 "created_at": "2016-12-16 15:56:59"
11 }
12 ]
13}

Get a job

Method

forge.jobs.get(server_id, job_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3const job = await forge.jobs.get(server_id, job_id);

Example Response

1{
2 "job": {
3 "id": 2,
4 "command": "COMMAND_THE_JOB_RUNS",
5 "user": "root",
6 "frequency": "Nightly",
7 "cron": "0 0 * * *",
8 "status": "installing",
9 "created_at": "2016-12-16 15:56:59"
10 }
11}

Delete a job

Method

forge.jobs.delete(server_id, job_id)

Usage

1const forge = new Forge('API_TOKEN');
2
3await forge.jobs.delete(server_id, job_id);

Edit this page on GitHub