Back to Cron Helper
Recipedatabasepostgresmaintenanceoptimization
PostgreSQL Vacuum Analyze
Automate PostgreSQL database maintenance with VACUUM ANALYZE.Over time, PostgreSQL tables accumulate dead rows and statistics become outdated. Running `VACUUM ANALYZE` reclaims storage and updates the query planner statistics, ensuring your database queries remain fast and efficient.
Cron Schedule
Command to Run
Copy and paste this command into your crontab or automation script
psql -U username -d dbname -c "VACUUM ANALYZE;"Implementation Examples
Unix/Linux Crontab
0 0 * * 1 /path/to/script.sh
Python (with schedule library)
schedule.every().monday.do(job)
Node.js (with node-cron)
cron.schedule('0 0 * * 1', () => {
console.log('Running every Monday');
});Go (with robfig/cron)
c.AddFunc("0 0 * * 1", func() { fmt.Println("Run every Monday") })GitHub Actions Workflow
- cron: "0 0 * * 1"
Related Cron Recipes
Automate PostgreSQL Backups Daily
databasepostgresbackup
Automate MySQL Backups Daily
databasemysqlbackup
Automate MongoDB Backups Daily
databasemongodbbackup
Automate Redis RDB Snapshots
databaserediscache
Rsync Incremental Backup
linuxbackupnetwork