# Bulk delete of spam accounts?

**URL:** <https://discuss.write.as/t/bulk-delete-of-spam-accounts/11811>\
**Category:** Instance Admins\
**Created:** [April 15, 2024, 10:24am UTC](https://discuss.write.as/t/bulk-delete-of-spam-accounts/11811 "2024-04-15T10:24:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![agger-magenta](https://discuss.write.as/user_avatar/discuss.write.as/agger-magenta/32/3399_2.png) [@agger-magenta](https://discuss.write.as/u/agger-magenta)\
**Post date:** [April 15, 2024, 10:24am UTC](https://discuss.write.as/t/bulk-delete-of-spam-accounts/11811/1 "2024-04-15T10:24:54Z")

</div>

I’m running an instance for my own blog at [agger — WriteFreely@Modspil.dk](https://freely.modspil.dk/agger/)

Naively, I had allowed open registration back in March. Today, to my horror, I see that I now have ~1200 spam accounts.

I started deleting them through the UI, but soon gave up - it’s taking too much time.

I SSH’ed to the server and deleted some with `writefreely user delete`, but that’s also a pain because you have to confirm deletion each time so it’s not easily scriptable. Also the `writefreely` program doesn’t allow me to list all users, so it’s not easily scriptable.

Does anyone know of there is an easy way to achieve this?

Thanks in advance for any response 🙂

---

<div class="post-metadata">

**Author:** ![agger-magenta](https://discuss.write.as/user_avatar/discuss.write.as/agger-magenta/32/3399_2.png) [@agger-magenta](https://discuss.write.as/u/agger-magenta)\
**Post date:** [April 15, 2024, 10:43am UTC](https://discuss.write.as/t/bulk-delete-of-spam-accounts/11811/2 "2024-04-15T10:43:42Z")

</div>

Also, I don’t understand why the spam blogs aren’t listed on the admin dashboard. Is there something I should enable?

---

<div class="post-metadata">

**Author:** ![agger-magenta](https://discuss.write.as/user_avatar/discuss.write.as/agger-magenta/32/3399_2.png) [@agger-magenta](https://discuss.write.as/u/agger-magenta)\
**Post date:** [April 16, 2024, 7:39am UTC](https://discuss.write.as/t/bulk-delete-of-spam-accounts/11811/3 "2024-04-16T07:39:19Z")

</div>

OK, so I found a solution I can kind of live with.

I made a small script which I named `delete`, like so:

```auto
#!/bin/bash

echo "deleting user $1"
echo 'y' | ./writefreely user d $1

```

Then I copy the list from `/admin/users`, one page at a time (there isn’t an option for showing all users at once), insert it into a file called `lusers`, and then I do

```auto
for luser in $(cat lusers| cut -d ' ' -f 1); do ./delete $luser; done

```

This is not really ideal … **EDIT:** I got it done rather quickly, though, by copying the users to the file one page at a time

---

<div class="post-metadata">

**Author:** ![val-vgms](https://discuss.write.as/user_avatar/discuss.write.as/val-vgms/32/4689_2.png) [@val-vgms](https://discuss.write.as/u/val-vgms)\
**Post date:** [July 19, 2026, 7:39pm UTC](https://discuss.write.as/t/bulk-delete-of-spam-accounts/11811/4 "2026-07-19T19:39:05Z")

</div>

A quick way to list all users (for instances powered by MariaDB) is accessing the database, listing all users, and sorting them by registration date.

```sh
mariadb -u writefreely -p -e "SELECT username FROM users ORDER BY created DESC" writefreely > users.txt

```

Then you just open the file, and erase the lines for the users you actually want to keep.

I was using a simple `for` script in Bash to parse the file, but the manual confirmation is tedious, so I’ll copy your delete script
