Cron Expression for Every 12 Hours
Run a cron job every 12 hours (twice daily) using 0 */12 * * *. Great for morning/evening batch jobs and digest emails.
Expression
0 */12 * * * Every 12 hours at minute 0
Use Cases
- • Sending morning and evening digest emails
- • Running twice-daily security scans
- • Generating AM/PM shift reports
- • Syncing data between time zones
Code Examples
Crontab
# Every 12 hours at minute 0
0 */12 * * * /path/to/your/script.sh GitHub Actions
name: Scheduled Job
on:
schedule:
- cron: '0 */12 * * *'
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: echo "Running Every 12 Hours" systemd Timer
[Unit]
Description=Every 12 Hours timer
[Timer]
OnCalendar=*-*-* *:*:00
Persistent=true
[Install]
WantedBy=timers.target Tips
- ✓ Runs at midnight and noon by default
- ✓ Use 0 6,18 * * * to run at 6 AM and 6 PM instead
- ✓ Twice-daily runs are ideal for summary reports
- ✓ Allows long-running tasks up to 12 hours
Frequently Asked Questions
Is 0 */12 * * * the same as 0 0,12 * * *?
Yes, both run at midnight (0:00) and noon (12:00). The */12 divides 24 hours into two 12-hour intervals.
How do I run twice a day at specific times?
Use 0 H1,H2 * * * where H1 and H2 are the hours you want. For example, 0 8,20 * * * runs at 8 AM and 8 PM.