As an alternative to one-time jobs, you can also run a command using remote execution from the CLI. This is simpler to do, but lacks the benefit of getting the history of jobs along with logs and status for each job.
To deploy a one-time job on Porter, head to the “Launch” tab and select the “Jobs” template. From this template, you can connect your source (Github repo or Docker image registry), specify the job command, and add environment variables. For example, to create a job that simply prints to the console from an environment variable, we can create a job with the following configuration:
After clicking “Deploy” and waiting for the Job to run successfully, you will be redirected to the “Jobs” tab where your jobs are listed. Click into the job you would like to view (in this case,
ubuntu-job), and the history of runs for that job will be shown. You can click on each job to view the logs:
To re-run the job, simply click the “Rerun job” button in the bottom right corner, which will re-run the job using the exact same configuration as before. You can view the configuration for this job from the “Main” tab, and you can delete the job (along with the history of all runs of the job) from the “Settings” tab.
To run a job as part of your application deployment process (for example, to run a migration script), see this document.
Deploying a cron job follows the same pattern as deploying a one-time job, but requires that you input a cron expression for the job to periodically run. To create cron expressions more easily, see this online editor for developing cron expressions.
As an example, we will once again create a job that simply prints to the console from an environment variable, but in this case we will create the job with a cron expression so that the job runs every minute:
After the cron job successfully deploys, you can navigate to the “Jobs” tab and click on your deployed job (in this case,
As you can see, the cron job runs every minute. By default, Porter will keep the history of the last 20 jobs run for that cron schedule.