How to Run a Job on a Schedule Only on Weekdays in GitHub Actions
A nightly job that fires every day wastes runs on weekends; the cron day-of-week field can limit it to working days.
Set the cron day-of-week field to 1-5 in on: schedule so the job runs Monday through Friday only.
Steps
- Add on: schedule with a cron expression.
- Set the fifth field, day of week, to 1-5 for Monday through Friday.
- Remember cron runs in UTC, so adjust the hour for your timezone.
- Keep the workflow on the default branch so the schedule registers.
Workflow
.github/workflows/weekday-job.yml
name: Weekday Job
on:
schedule:
- cron: '0 6 * * 1-5'
jobs:
run:
runs-on: ubuntu-latest
steps:
- run: echo "runs 06:00 UTC Mon-Fri"Notes
- Scheduled runs always use UTC, so a 6am local job needs the hour offset by your timezone.
- Latchkey managed runners run these scheduled jobs cheaper and self-heal on runner loss.
Related guides
How to Run a Job on a Schedule with a Timezone in GitHub ActionsSchedule a GitHub Actions job with cron and handle timezones correctly, since schedule cron is always UTC, by…
How to Schedule a GitHub Actions Workflow (Cron)Schedule a GitHub Actions workflow with on.schedule and cron syntax - UTC timing, multiple schedules, and why…