Skip to content

Scheduled Publishing with Cron for Quartz Sites

Scheduled Publishing with Cron for Quartz Sites

Section titled “Scheduled Publishing with Cron for Quartz Sites”

Set up automatic publishing for your Quartz site using cron. Configure twice-daily automatic deployments so your site stays updated without manual intervention.

  1. What You’ll Build
  2. Prerequisites
  3. Setup Instructions
  4. Testing Your Cron Jobs
  5. Monitoring and Maintenance
  6. Troubleshooting

Automatic publishing system that:

  • Publishes your Quartz site twice daily (9 AM and 6 PM)
  • Runs on your always-on Mac mini
  • No manual intervention needed
  • Works alongside your Alfred workflows
  • Logs all publish attempts for review

The automated workflow:

Edit in Obsidian → Files sync automatically → Cron triggers → Quartz builds → Site live

Why scheduled publishing?

  • Never forget to publish changes
  • Consistent update schedule
  • Hands-free operation
  • Works while you’re away

Time to complete: 10-15 minutes


Before setting up cron, you must have:

  • Alfred workflows set up and working
    • Your publish.sh script must be working
  • Always-on Mac (Mac mini recommended)
    • System Settings → Energy → Prevent sleeping: ON
  • Executable script:
    Terminal window
    chmod +x ~/Developer/mementropy-quartz/scripts/publish.sh

Test that manual publishing works:

Terminal window
cd ~/Developer/mementropy-quartz && ./scripts/publish.sh

If this fails, fix the publish script first before setting up cron.


Terminal window
crontab -e

This opens the cron editor (vim by default).

If you’ve never used vim:

  • Press i to enter INSERT mode
  • When done: Press Esc, type :wq, press Enter to save

Add these lines:

# Quartz automated publishing - 9 AM daily
0 9 * * * cd $HOME/Developer/mementropy-quartz && ./scripts/publish.sh >> /tmp/quartz-publish.log 2>&1
# Quartz automated publishing - 6 PM daily
0 18 * * * cd $HOME/Developer/mementropy-quartz && ./scripts/publish.sh >> /tmp/quartz-publish.log 2>&1

What these lines do:

  • 0 9 * * * - Run at 9:00 AM every day
  • 0 18 * * * - Run at 6:00 PM every day
  • cd $HOME/Developer/mementropy-quartz - Change to your Quartz project
  • ./scripts/publish.sh - Run the publish script
  • >> /tmp/quartz-publish.log 2>&1 - Append output to log file

Save (:wq in vim), then verify:

Terminal window
crontab -l

You should see your two entries.


* * * * * command
| | | | |
| | | | +--- Day of week (0-7, Sunday = 0 or 7)
| | | +----- Month (1-12)
| | +------- Day of month (1-31)
| +--------- Hour (0-23)
+----------- Minute (0-59)
PatternMeaning
0 9 * * *Every day at 9 AM
0 18 * * *Every day at 6 PM
0 9,18 * * *Daily at 9 AM and 6 PM (single line)
0 12 * * 1-5Weekdays at noon
*/30 * * * *Every 30 minutes

Use crontab.guru to test expressions.


Create a test job that runs in 2 minutes:

  1. Check current time: date
  2. Edit crontab: crontab -e
  3. Add test job (adjust time to 2 minutes from now):
    # TEST - Remove after verifying
    32 14 * * * cd $HOME/Developer/mementropy-quartz && ./scripts/publish.sh >> /tmp/quartz-test.log 2>&1
  4. Save and wait
  5. After 2 minutes: cat /tmp/quartz-test.log
  6. Remove test job

After 9 AM or 6 PM:

Terminal window
tail -50 /tmp/quartz-publish.log

Expected output:

  • Build output from Quartz
  • Git commit/push messages
  • “Published successfully” or “No content changes”
  1. Make a change to any content file
  2. Wait for next cron run
  3. Check site ~3 minutes after scheduled time
  4. Your change should be visible

Terminal window
# Last 50 lines
tail -50 /tmp/quartz-publish.log
# Today's entries
grep "$(date +%Y-%m-%d)" /tmp/quartz-publish.log
# Count today's publishes
grep "$(date +%Y-%m-%d)" /tmp/quartz-publish.log | wc -l

Add to crontab to keep log manageable:

# Rotate log monthly (1st of month at midnight)
0 0 1 * * tail -1000 /tmp/quartz-publish.log > /tmp/temp.log && mv /tmp/temp.log /tmp/quartz-publish.log

Check cron is running:

Terminal window
ps aux | grep cron

Check script permissions:

Terminal window
ls -la ~/Developer/mementropy-quartz/scripts/publish.sh
# Should show: -rwxr-xr-x

Test script manually:

Terminal window
cd ~/Developer/mementropy-quartz && ./scripts/publish.sh

Check paths:

Terminal window
crontab -l
# Verify paths are correct

Give cron Full Disk Access:

  • System Settings → Privacy & Security → Full Disk Access
  • Add /usr/sbin/cron
  1. Check cron ran: grep "$(date +%Y-%m-%d)" /tmp/quartz-publish.log
  2. Check for changes: Log shows “No content changes”?
  3. Check GitHub Actions: Visit repo Actions tab
  4. Wait for deployment: Takes 2-3 minutes after push

Temporarily (comment out):

Terminal window
crontab -e
# Add # at start of lines

Permanently:

Terminal window
crontab -e
# Delete the lines

Use both Alfred and cron together:

MethodWhen to Use
Alfred publishImmediate publishing, testing
CronRegular automatic updates

They use the same script, so they work seamlessly together.

Typical workflow:

  1. Write content throughout the day
  2. Use preview to test locally
  3. Either publish immediately or let cron handle it

Terminal window
crontab -l # List jobs
crontab -e # Edit jobs
crontab -r # Remove ALL jobs (careful!)
Terminal window
tail -f /tmp/quartz-publish.log # Watch live
cat /tmp/quartz-publish.log # View all

Visit crontab.guru to test cron expressions.



Last updated: 2025-01-13