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
- • Sending morning and evening notification digests
- • Running AM/PM data synchronization
- • Checking system health at start and end of business
- • Processing orders twice daily
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 Tips
- ✓ Use comma-separated values in the hour field for specific times
- ✓ Adjust hours to match your business schedule
- ✓ Consider 0 0,12 * * * for midnight and noon instead
- ✓ Each execution is independent and can run different logic based on time
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 * * *.