Scripts and Scheduled Runs

Like other features on the Platform (Sessions, APIs, etc.), you can run scripts in isolated containers with dedicated server resources. The Runs and Scheduled Runs features let you execute code, view logs, and collect outputs.

Warning

Spark scripts and scheduled runs are not supported in Platform version 5.0.

Run a Script

There are two ways to run a script. You can either navigate to a file’s preview page and click the Run button in the top right, or use the Run a Script option in the Actions menu. Select the script to run by typing the path to the file and use the autocomplete feature. Configure the script run by choosing hardware size, language, environment, and a repo branch.

_images/Run-a-script.png

You can check the status of your run in the Run Details page. This can be reached by clicking on the run from the Activity tab of the project.

_images/Activity-feed.png

The Run Details Page

The Run Details page shows the configuration of the container that ran the script, as well as the process’s Standard Out and Standard Error. Standard Out will display anything that was printed by the script to stdout. Standard Error shows anything printed by the script to stderr.

_images/Run-details-page.png

Schedule a Run

You can schedule scripts to run at regular intervals. To schedule a script, pick the Schedule a Run option from the Actions menu and select the file you wish to schedule. You’ll find the same environment configuration options here, with the addition of the schedule timing.

To specify how often the script should run, you can choose from a set of standard options (hourly, daily, weekly, monthly) or specify a custom schedule.

_images/Schedule-a-run-basic.png

Custom Schedules

Aside from the Hourly, Daily, Weekly, and Monthly options, you can define a custom cron syntax schedule.

The custom schedule syntax can have five or six arguments separated by spaces. Each argument corresponds to the following:

  • Seconds (optional): 0-59 (e.g., 10 would run 10 seconds after the start of a minute)
  • Minutes: 0-59
  • Hours: 0-23
  • Day of Month: 1-31
  • Months: 0-11 (note that January is 0)
  • Day of Week: 0-6 (note that Sunday is 0)

Leaving out seconds will default to running at 0 seconds. You can also replace any of the arguments with *, which means run no matter what the value is. For example, 30 15 10 5 1 * will run at 10:15 am and 30 seconds, on February 5th, no matter what day of the week.

You can also use commas to specify lists of values, dashes to specify ranges, and slashes to specify increments. See below for more examples or check the official documentation on node-cron.

  • 30 15 10 5 1 \* - Run at 10:15:30 am on February 5th, no matter what day of the week
  • 30 15 10 5 1 2 - Run at 10:15:30 am on February 5th, but only if it is a Tuesday
  • 0 0 \* 0-3 6 - Run at midnight on every Saturday in January through April
  • 0 0 \* 2,4 6 - Run at midnight on every Saturday in March and July
  • 0 */30 15 * \* - Run every 30 minutes on the 15th of every month, no matter what day of the week

Schedule Details Page

You can reach a job’s Schedule Details page from the Activity feed. This page shows you all past runs (with links to the Run Details pages), and lets you edit the frequency of the job. To edit anything other than the frequency (e.g., the hardware for the container), you need to create a new job. You may also stop all future runs for the job from the Schedule Details page.

_images/Schedule-details.png