CronTool
Cron expression editor & debugger
Question

How can I run a script 20 times a day at random times, between 9am and 11pm?

Answer

That cannot be entirely done with cron, but you could use this to get the desired result:


15,45 8-21 * * * sleep ${RANDOM:0:2}m ; /path/to/script.sh
Why this matters

Cron only matches clock-aligned minutes, so “truly random” times within a window need a wrapper. The trick above schedules deterministic base times (every hour from 8 AM to 9 PM, at :15 and :45 — 28 runs) and adds a random delay before launching the actual script. ${RANDOM:0:2} yields a 1-2 digit number (0-99); sleep ...m waits that many minutes. Combined, each run fires somewhere in a ~99-minute jitter window after the scheduled minute.


The “20 times a day” ask is hard to satisfy exactly without a workflow engine. The pragmatic version: schedule slightly more than you need (e.g. 28 base slots) and have the script self-skip — keep a counter file, increment it, exit early once you've hit 20 runs. Or use a stochastic gate: [ $((RANDOM % 28)) -lt 20 ] || exit 0 gives ~20 runs per day on average.


Jenkins users have a cleaner option: the H hash modifier automatically jitters the minute deterministically per job. See the Jenkins cron guide for that pattern.

Read the dedicated guide: Cron every day.

Cron schedule used

Calendar

View future cron matches in a calendar

April 2026

Showing next 1000 cron schedules

Loading...

See this cron expression on the calendar → view example

Related cron questions

Other answers and worked examples for the most confusing cron expressions.

QuestionHow do you run a cron job every minute only on specific hours?
QuestionHow do I set up a cron job that runs every day at 1PM, 2PM and 3PM?
QuestionI want to execute a task every 20 minutes, starting at 5 past the hour, is it possible to achieve this with Cron?
QuestionHow can I set up a cron job to run every night at 2:30? I am familiar with configuring it to run at 2:00, but not 2:30.

Ready to schedule it?

Point Crontap at any URL. Pick any cron. Done.

WordPress, Shopify, Railway, Cloud Run, Vercel, HubSpot, Ghost, your own box. If it answers HTTP, Crontap can drive it on a clock you can read, in the timezone that actually matters, and page you when something breaks.

Free forever tier ・ No credit card required

Your next schedule
GET/wp-cron.php?doing_wp_cron=1

Schedule

every 5 minutes

Next run

in 23s

Permalink: https://tool.crontap.com/help/cron-job-run-script-at-random-times-between-two-hourly-intervals

Apihustle Logo

This tool is part of the Apihustle suite - a collection of tools to test, improve and get to know your API inside and out.

  • Clobbr logo

    Clobbr

    The app & CLI tool to test API endpoint speed.

    Visit
  • Crontap logo

    Crontap

    Schedule recurring API calls using cron syntax.

    Visit
  • CronTool logo

    CronTool

    Debug multiple cron expressions on a calendar.

    Visit

  • Page AI

    AI Website Generator that designs and writes clean code.

    Visit
  • Shipixen

    Generate customized boilerplates in minutes.

    Visit
  • Page UI

    Landing page UI components for React & Next.js

    Visit