Last active
June 28, 2026 14:23
-
-
Save El3k0n/af6b611d1bd38f834cd01a505a006252 to your computer and use it in GitHub Desktop.
Keepalive for Supabase Projects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # keepalive_supabase.sh | |
| # | |
| # Periodically pings Supabase project REST endpoints to prevent automatic | |
| # pausing of free-tier projects due to inactivity (Supabase pauses projects | |
| # after 1 week of inactivity on the free plan). | |
| # | |
| # Usage: run manually or via cron. | |
| # Recommended cron schedule (every 3 days at 9:00 AM): | |
| # 0 9 */3 * * $HOME/keepalive_supabase.sh | |
| # | |
| # Logs each ping result (timestamp + HTTP status code) to ~/keepalive_supabase.log | |
| PROJECTS=( | |
| "https://PROJECT_1_REF.supabase.co" | |
| "https://PROJECT_2_REF.supabase.co" | |
| ) | |
| KEYS=( | |
| "ANON_KEY_PROJECT_1" | |
| "ANON_KEY_PROJECT_2" | |
| ) | |
| # Table that exists in each project (used for a lightweight read query). | |
| # RLS may return an empty array, but the request still counts as activity | |
| # and returns HTTP 200. | |
| TABLES=( | |
| "table1" | |
| "table2" | |
| ) | |
| LOGFILE="$HOME/keepalive_supabase.log" | |
| timestamp=$(date '+%Y-%m-%d %H:%M:%S') | |
| for i in "${!PROJECTS[@]}"; do | |
| URL="${PROJECTS[$i]}/rest/v1/${TABLES[$i]}?select=id&limit=1" | |
| KEY="${KEYS[$i]}" | |
| response=$(curl -s -o /dev/null -w "%{http_code}" --max-time 10 \ | |
| -H "apikey: $KEY" \ | |
| -H "Authorization: Bearer $KEY" \ | |
| "$URL") | |
| echo "[$timestamp] ${PROJECTS[$i]} → $response" >> "$LOGFILE" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment