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');23const 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
Key | Description |
---|---|
command | The command to run. |
frequency | The frequency in which the job should run. Valid values are minutely , hourly , nightly , weekly , monthly , reboot , and custom . |
user | The server user to run the command as. |
minute | Required if the frequency is custom . |
hour | Required if the frequency is custom . |
day | Required if the frequency is custom . |
month | Required if the frequency is custom . |
weekday | Required 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');23const 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');23const 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');23await forge.jobs.delete(server_id, job_id);
Edit this page on GitHub