Skip to content

Instantly share code, notes, and snippets.

@iaminamcom
Last active January 13, 2025 10:51
Show Gist options
  • Save iaminamcom/c7184053d56dc9404cad423b8b827461 to your computer and use it in GitHub Desktop.
Save iaminamcom/c7184053d56dc9404cad423b8b827461 to your computer and use it in GitHub Desktop.
How to add CRON jobs in Caprover

I was trying to add CRON jobs and found no guide. So here are the steps I followed

  1. mkdir cron && cd cron Creates directory and change into it.
  2. git init New git initialization.
  3. touch captain-definition Creates new captain config file.
  4. In captain-definition add folowing code. It'll loads jobber image which works fine even if deprecated. We just need it to run a task in a schedule.
{
  "schemaVersion": 2,
  "dockerfileLines": [
    "FROM jobber"
  ]
}

or you can try

{
  "schemaVersion": 2,
  "templateId": "jobber"
}
  1. git add . && git commit -m 'New cron job for xxx' It'll add to git.
  2. caprover deploy Run it to deploy as for other apps.

Everything deployed!

Now add tasks

  1. SSH into your server
  2. docker container ls See all running containers and copy ID of the cron (or what you named) container.
  3. docker exec -it <ID_HERE> sh You'll move into container.
  4. cd /home/jobberuser/ && vi .jobber Write your task following guide here and save it.
  5. exit exits container and then run docker restart <ID_HERE> to restart container.

We're all done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment