🎓 Solvo

Cron Jobs

Five background scripts keep fee reminders, overdue tracking, and attendance alerts running on their own schedule.

Every script here is a plain PHP CLI script — run with php /path/to/project/scripts/whatever.php, no web server involvement, no arguments needed for any of them. Each is idempotent (safe to run twice in a row without duplicating anything or double-charging anyone) unless noted otherwise.

The five scripts

ScriptWhat it doesSuggested schedule
mark_overdue_invoices.php Flips subscription_invoices from pending to overdue once due_date passes. Daily, early morning
generate_term_invoices.php Generates that term's subscription_invoices for every active, full-platform school, based on each school's own subscription_plans.term_length_months. Once per term (manual trigger is fine too — see note below)
mark_overdue_library_loans.php Flips library_loans from active to overdue once due_date passes. Cosmetic status only — the return workflow and fine calculation both work the same regardless of whether this has run. Daily
send_attendance_alerts.php Sends a notification (SMS/email) to guardians when a student is marked absent that day. Daily, after attendance is expected to be marked (e.g. mid-morning)
send_fee_reminders.php Sends a reminder to guardians whose student_fee_balances.due_date is approaching or has passed. Daily
On generate_term_invoices.php: unlike the other four, this one doesn't need a fixed daily cadence — it makes sense once per term, and running it twice for the same period is harmless (it's driven by each school's actual term dates, not a blind "run every N days" assumption) but also pointless. Many operators prefer to trigger this manually rather than scheduling it — either is fine.

Example crontab (VPS / any server with real cron access)

# Solvo — adjust the PHP path and project path for your server.
0 1 * * * /usr/bin/php /var/www/mojamoza/scripts/mark_overdue_invoices.php >> /var/log/mojamoza-cron.log 2>&1
0 2 * * * /usr/bin/php /var/www/mojamoza/scripts/mark_overdue_library_loans.php >> /var/log/mojamoza-cron.log 2>&1
0 9 * * * /usr/bin/php /var/www/mojamoza/scripts/send_attendance_alerts.php >> /var/log/mojamoza-cron.log 2>&1
0 10 * * * /usr/bin/php /var/www/mojamoza/scripts/send_fee_reminders.php >> /var/log/mojamoza-cron.log 2>&1
# generate_term_invoices.php: run manually at the start of each term, or uncomment for a quarterly nudge
# 0 3 1 1,4,9 * /usr/bin/php /var/www/mojamoza/scripts/generate_term_invoices.php >> /var/log/mojamoza-cron.log 2>&1

Find your PHP binary's path with which php (VPS) — shared hosts usually give you a specific path in their control panel instead (see below).

cPanel — Cron Jobs UI

For each script, add a cron job with:

Repeat for each of the five scripts, one cron job entry per script.

Verifying a cron job actually ran

Every script prints a short summary line to stdout when it finishes (e.g. "Marked 3 loan(s) overdue."). If you redirected output to a log file (as in the crontab example above), check that file. If a cron job silently does nothing every day, the most common cause on shared hosting is the PHP path being wrong — cPanel often has multiple PHP versions installed under different paths, and cron doesn't use the same PATH your shell does.