Skip to content
Weik.ioUniversity
Try Weik.io

Running a script on a cron schedule

Patterns 7 · 3:18

A schedule runs a script on an agent at set times, and each run leaves logs and a run record. Only exit code 0 is a success, and any other code fails the run.

Download the mp4Recorded on 2026.2.2

What it covers

  • The script that cleans up old export files on a devtest server
  • The schedule the Weik.io CLI writes with weikio init
  • The six-field cron in UTC, which the admin UI says in words
  • The deployment's logs, read with weikio logs or the schedule's Logs section
  • Each run record in the Runs section, with its exit code and outcome
  • The failed run in the Runs section, listed with exit code 3

Commands in this video

Terminal
$ weikio init cleanup --kind schedule
$ weikio run ./cleanup --no-logs
$ weikio logs finance/cleanup --since 1m
Transcript
  1. 0:01A script must run at set times on a server, and a failed run must show as failed.
  2. 0:11A script on a devtest server in your Weik.io
  3. 0:14installation cleans up old export files.
  4. 0:17When the script fails, exit code 3 stays on that server.
  5. 0:21Weik.io runs the script from a schedule and keeps logs and a run record.
  6. 0:30The Weik.io CLI writes the schedule with weikio init.
  7. 0:40The schedule runs a command on an agent, so you write no route.
  8. 0:45The cron has six fields, seconds first, in UTC, and runs every minute at second 0.
  9. 0:52The admin UI says the cron in words.
  10. 1:00The deployment's logs collect every line the script writes,
  11. 1:03to standard output or standard error.
  12. 1:06The closing line says how the command ended: 0, or another code with the error.
  13. 1:12Read the log lines with weikio logs or the schedule's Logs section.
  14. 1:19Each run leaves a run record with its start and end, its exit code and outcome.
  15. 1:25The run records are in the admin UI's Runs section, newest first.
  16. 1:31Only exit code 0 is a success, and any other code fails the run.
  17. 1:40weikio run publishes the folder, then deploys it to devtest.
  18. 1:51The agent runs the script when the cron fires, and the run's lines reach the logs.
  19. 2:00The run record marks a success, and weikio logs fetches those lines.
  20. 2:11The script can't open its exports folder and exits with 3.
  21. 2:15The closing line gives the exit code and error.
  22. 2:19The run record marks the failure.
  23. 2:25Once the exports folder is back,
  24. 2:27you use Run now to start the command without waiting for the cron,
  25. 2:32and see what it printed.
  26. 2:39Every run is in the Runs section, and the failed one is listed with exit code 3.
  27. 2:47The cron appears in words in the Integrations list, with the schedule's command.
  28. 2:57A schedule with its cron runs the command on the agent's host.
  29. 3:01The logs carry what the command printed, closing with the exit code.
  30. 3:05A run record keeps the outcome, and every run is in the Runs section.

Sign in to the live demo

Sign in with the shared viewer account, which can open every screen of the example projects and can't change anything.

E-mail
viewer@demo.weik.io
Password
try-weikio-live-demo
Open the live demo