---
title: "Script to periodic closure of the Planning Poker sessions"
canonical: "https://support.appfire.com/space/SUPPORT/599523920/Script+to+periodic+closure+of+the+Planning+Poker+sessions"
format: markdown
---
This guide explains how to execute or schedule a script to close overdue poker sessions older than a specified date. The script can be run on any Linux machine with the `psql` terminal client installed.

## Prerequisites

- Go to the terminal and ensure the `psql` client is installed on your machine. If not, install it using `apt`. Then, verify the installation by checking the `psql` version:

## Runbook

1. Log in to the `psql` and the specific db schema and execute the following script:

> ⚠️ Replace `01/03/2021` in the `TO_DATE` function with the desired date in `DD/MM/YYYY` format.

3. You can also set up a cron job to automate this process at regular intervals. To do this, you will need to create an SQL file on your local machine and then execute it using cron.
4. Use `CURRENT_DATE -30` to close the session created 30 days ago, and using VIM, create a file script.sql:

> ℹ️ To run the script automatically, please ensure you provide the password. You can do this in one of the following ways:
> ℹ️ 
> ℹ️ 1. Set the PGPASSWORD environment variable. For details, see the manual:  
> ℹ️ [http://www.postgresql.org/docs/current/static/libpq-envars.html](http://www.postgresql.org/docs/current/static/libpq-envars.html)
> ℹ️ 2. Use a .pgpass file to store the password. For details, see the manual:  
> ℹ️ [http://www.postgresql.org/docs/current/static/libpq-pgpass.html](http://www.postgresql.org/docs/current/static/libpq-pgpass.html)
> ℹ️ 3. Use "trust authentication" for that specific user: [http://www.postgresql.org/docs/current/static/auth-methods.html#AUTH-TRUST](http://www.postgresql.org/docs/current/static/auth-methods.html#AUTH-TRUST)