---
title: "How to automatically delete old backup files"
description: "Automatically deleting old backup files prevents disk space from filling up and avoids errors or crashes in OP5 Monitor. This FAQ provides a cronjob command to delete backup files older than 7 days and guidance on managing backup directories."
url: "https://docs.itrsgroup.com/docs/faq/op5/11390733307549-op5-monitor-how-to-automatically-delete-old-backup-files/index.html"
---
One way to automatically remove old backup files is to create a cronjob.

To create a cronjob to automatically delete old backup files older than 7 days every day at 1 AM please copy/paste the following line and run it as root user.

```
echo "0 1 * * * root find /path/to/backups/* -mtime +7 -exec rm {} \; > /dev/null 2>&1" > /etc/cron.d/op5-removebackups
```

Please change */path/to/backups/\* to the location of your backup directory.*

To manually run the command:

```
find /path/to/backups/* -mtime +7 -exec rm {} \;
```

If you only want to list/print the files:

```
find /path/to/backups/* -mtime +7 -exec ls -l {} \;
```

It is necessary to delete old backup files to avoid filling up the disk. If the disk or mount is full you will get an error pop-up like below when saving changes.

```
[Errno 28] No space left on device
```

![OP5 Monitor - How to automatically delete old backup files](https://docscdn.itrsgroup.com/faq/images/op5/11390733307549-11390848166557-mceclip0.png)

If the disk is full OP5 Monitor might also crash and show the below error message:

`Exception during error handler: A session had already been started - ignoring session_start() #0 [internal function]: Kohana::error_handler(8, 'A session had a...', '/opt/monitor/op...', 54, Array) #1 /opt/monitor/op5/ninja/system/libraries/Session.php(54): session_start() #2 /opt/monitor/op5/ninja/system/libraries/Session.php(25): Session->__construct() #3 /opt/monitor/op5/ninja/modules/auth/libraries/Auth.php(56): Session::instance() #4 /opt/monitor/op5/ninja/application/config/exception.php(26): Auth::instance() #5 /opt/monitor/op5/ninja/system/core/Kohana.php(452): require('/opt/monitor/op...') #6 /opt/monitor/op5/ninja/system/core/Kohana.php(365): Kohana::config_load('exception', true) #7 /opt/monitor/op5/ninja/application/views/kohana_error_page.php(35): Kohana::config('exception.shell...') #8 /opt/monitor/op5/ninja/system/core/Kohana.php(665): require('/opt/monitor/op...') #9 /opt/monitor/op5/ninja/system/core/Kohana.php(208): Kohana::exception_handler(Object(Kohana_PHPError_Exception)) #10 [internal function]: Kohana::instance() #11 /opt/monitor/op5/ninja/system/core/Event.php(218): call_user_func(Array) #12 /opt/monitor/op5/ninja/system/core/Bootstrap.php(59): Event::run('system.execute') #13 /opt/monitor/op5/ninja/index.php(98): require('/opt/monitor/op...') #14 {main}`

To troubleshoot disk space-related problems please refer to <https://support.itrsgroup.com/hc/en-us/articles/9245598481949>


