---
title: "rm: Argument list too long - improved speed"
date: "2013-03-04"
path: "/44-rm-argument-list-too-long-improved-speed.html"
section: "/ramblings"
aliases:
  - "/44"
  - "/44-rm-argument-list-too-long-improved-speed"
  - "/44.html"
  - "/ramblings/44-rm-argument-list-too-long-improved-speed.html"
---

Create a shell script containing:

```
#!/bin/sh
ionice -c 3 find /home/<sitename>/public_html/var/session/ -name 'sess*' -mtime +3 -type f -delete
```

Replacing the "&lt;sitename>" value with you own location. This will lower the priority of the command in the O/S and also use the "find" commands own delete mechanism which all-in-all is much faster than passing it to rm.

This can then be added to CRON using `cron -e` so that it executes on a regular basis:

```
# remove magento sessions
0 3 * * *  /bin/sh /home/<sitename>/session_cleanup.sh
```
