Check the last time a space was modified?
Asked by Victor Prasad:

Hello,

We have way too many abandoned spaces. Is there any way I can see which spaces have not been modified in a year?

We do have ScriptRunner installed. It has an option for all last modied pages. Anyway to do this for a space?

Thanks,

Mr. V


Answers:
author: AhmadDanial
body: Hello, Victor.

The easiest way to determine the last modified date for spaces is to query it from the database itself. For example:

```
SELECT spacename, spacekey, lastmoddate FROM spaces;
```

There might be better ways of obtaining these kind of information as well through third-party add-on, for example [Reporting for Confluence](https://marketplace.atlassian.com/apps/186/reporting-for-confluence?hosting=server&tab=overview).

comments: author: Victor Prasad
body: Thank you VERY much.

I filtered it further using the SPACETYPE (global vs personal)

Trying to get people to clean up their spaces...herding cats.


author: AhmadDanial
body: Hi, Victor.

You are most welcome. Thanks for sharing your solution as well. Ultimately, you used the following SQL query to pull the information from the database:

```
SELECT spacename, spacekey, spacetype, lastmoddate FROM spaces;
```

I can only imagine when the instance gets bigger and unmanageable. So, it's good to perform some housekeeping to keep it at its optimum level.


author: Victor Prasad
body: Hi Ahmad,

Have any strategies for keeping those abandoned sites to a minimum?

Besides begging?

Thanks,

V


author: AhmadDanial
body: Hello, Victor.

If the space is really not needed anymore, it will be best to reach out to the owners and ask them to properly delete them. You can bulk delete spaces but a third-party addon is needed - [Is it possible to bulk delete Spaces in Confluence.](https://community.atlassian.com/t5/Confluence-questions/Is-it-possible-to-bulk-delete-Spaces-in-Confluence/qaq-p/594160)

If there might come a time when the space and its contents needs to be reviewed again, you can consider [archiving the space](https://confluence.atlassian.com/doc/archive-a-space-284368719.html) and it won't appear in the instance unless searched.

If the space could still be useful, keep it and ask the owners to update it with the necessary content (pages / blog post / meeting notes).


author: Victor Prasad
body: The issue here is most space owners just leave their spaces or leave the organization and we have all these orphaned spaces.

I have found a problem with the script. While it returns a data (last modified) it is not what appears on the page.

For example the script is showing a date of 2010-04-12 but when I go to the space homepage it shows 2018-08-23...this year last modified by...

So what exactly is this date showing me? A page? Which page?

Any ideas?

Thanks for your ongoing support!


author: AhmadDanial
body: Hello, Victor.

My sincere apologies as I was looking at the wrong information. I double checked on my end and verified that the table that we should **also** be looking at is actually the **content**table as well.

    SELECT spaces.spacename, MAX(content.lastmoddate) FROM content, spaces WHERE content.spaceid = spaces.spaceid GROUP BY spaces.spacename;?

Please try running the query above which should identify the last date on which content was modified in each space within a single Confluence instance. Let me know how it goes on your end.


author: Victor Prasad
body: ++**no need to apologize - you are helping me!!!!!**++

I am using this:

SELECT SPACES.SPACENAME, MAX(CONTENT.LASTMODDATE)  
FROM CONTENT, SPACES  
WHERE CONTENT.SPACEID = SPACES.SPACEID AND SPACES.SPACETYPE like 'global'  
GROUP BY SPACES.SPACENAME;

and I see results - need to go validate a few - but I think we are good!


author: AhmadDanial
body: Hi, Victor.

You are always welcome. Good catch on the additional parameters in the SQL query:

```
AND SPACES.SPACETYPE like 'global'
```

Always happy to help!


Tags: confluence-server

server