T
ToolPrime

Cron Expression for Twice a Day

Run a cron job twice daily at 8 AM and 8 PM using 0 8,20 * * *. Useful for morning and evening batch processing.

Expression

0 8,20 * * *

At 08:00 and 20:00 every day

Use Cases

Code Examples

Crontab

# At 08:00 and 20:00 every day
0 8,20 * * * /path/to/your/script.sh

GitHub Actions

name: Scheduled Job
on:
  schedule:
    - cron: '0 8,20 * * *'
jobs:
  run:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: echo "Running Twice a Day"

systemd Timer

[Unit]
Description=Twice a Day timer

[Timer]
OnCalendar=*-*-* *:*:00
Persistent=true

[Install]
WantedBy=timers.target

node-cron (Node.js)

import cron from 'node-cron'

// At 08:00 and 20:00 every day
cron.schedule('0 8,20 * * *', () => {
  console.log('Running Twice a Day')
})

Spring (@Scheduled, Java)

// At 08:00 and 20:00 every day
@Scheduled(cron = "0 0 8,20 * * *")
public void run() {
    // your task
}

Spring cron has 6 fields (a leading seconds field), so a 0 is prepended to the standard 5-field expression.

Tips

Frequently Asked Questions

How do I run a cron job twice a day?

List two hours separated by a comma: 0 8,20 * * * runs at 8 AM and 8 PM. You can choose any two hours.

Can I run at different minutes for each time?

Not in a single expression. You would need two separate cron entries, for example: 15 8 * * * and 45 20 * * *.

Related Cron Expressions

Related Tools