# Housekeeping

{% hint style="danger" %}
For MongoDB log file, you should use the [logrotate](/dmk-mongodb/monitoring-and-maintenance/log_rotation.md) utility and not the `housekeeping.py` tool !
{% endhint %}

**dbi services** provides a cleaning script named `housekeeping.py` that performs several types of operations on log files.

* Deletion of old files
* Truncation of files
* Compression of old files
* Archiving of files (truncation + compression)

The script should be run as `housekeeping.py -c $MONGO_BASE/etc/housekeeping.conf`. You can find a template for the `housekeeping.conf` file in `$DMK_HOME/templates/etc/housekeeping.conf`.

#### Default settings

You can set default settings for the main operations with the `DEF` keyword:

{% code title="$MONGO\_BASE/etc/housekeeping.conf" overflow="wrap" lineNumbers="true" %}

```bash
DEF::DELET::100:: # Delete files older than 100 days
DEF::TRUNC::1000:: # Keep the last 1000 lines
DEF::ARCHI::1000:: # Backup the file and keep the last 1000 lines
DEF::COMPR::100:: # Compress files only if older than 100 days
```

{% endcode %}

#### Custom settings

You can define custom paths that you want to be cleaned with the `CST` keyword:

{% code title="$MONGO\_BASE/etc/housekeeping.conf" overflow="wrap" lineNumbers="true" %}

```bash
CST::/u01/app/mongodb/local/dmk/log/js/*.js::DELET::1:: # Delete JS files older than one day, to clean DMK internal folder.
```

{% endcode %}

{% hint style="danger" %}
For MongoDB log file, you should use the [logrotate](/dmk-mongodb/monitoring-and-maintenance/log_rotation.md) utility and not the `housekeeping.py` tool !
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dbi-services.gitbook.io/dmk-mongodb/monitoring-and-maintenance/housekeeping.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
