# Deactivating idle users after custom period script is not finding all idle users

**URL:** <https://forum.library.adaptavist.com/t/deactivating-idle-users-after-custom-period-script-is-not-finding-all-idle-users/548>\
**Category:** Scripts\
**Tags:** data-center, jira\
**Created:** [December 29, 2024, 8:54pm UTC](https://forum.library.adaptavist.com/t/deactivating-idle-users-after-custom-period-script-is-not-finding-all-idle-users/548 "2024-12-29T20:54:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![avalonian](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@avalonian](https://forum.library.adaptavist.com/u/avalonian)\
**Post date:** [December 29, 2024, 8:54pm UTC](https://forum.library.adaptavist.com/t/deactivating-idle-users-after-custom-period-script-is-not-finding-all-idle-users/548/1 "2024-12-29T20:54:40Z")

</div>

Hey all, I am trying to use this script to deactivate all users after 365 days:

> **[Deactivate Idle Users After a Custom Period - Adaptavist Library](https://library.adaptavist.com/entity/deactivate-inactive-users-after-custom-period)**
>
> \#### Overview
> 
> Running this script from the \*Script Console\* to deactivate users that have been inactive for the set time period.
> 
> \#### Example
> 
> Over time employees move teams or move to different parts of the business, meaning they are taking up...

I have updated numOfDays to 365, but the script only found users up to a certain username alphabetically. It stopped somewhere in the 'E’s. I cannot get it to find anymore idle users, despite confirming there are still plenty of ‘active’ idle users.

Not sure if this is relevant, but each time a ran the script (had to run it 4-5 times for it to deactivate users A-E alphabetically) it deactivated less and less users each time. The first run was around 450 users, and it got exponentially smaller after that (i.e. run 1: deactivated 450 users, run 2: deactivated 90 users, run 3: deactivated 15 users, run 4: deactivated 1 user.

Any help would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![nikolayr](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.library.adaptavist.com/nikolayr/32/254_2.png) [@nikolayr](https://forum.library.adaptavist.com/u/nikolayr)\
**Post date:** [January 7, 2025, 4:31pm UTC](https://forum.library.adaptavist.com/t/deactivating-idle-users-after-custom-period-script-is-not-finding-all-idle-users/548/2 "2025-01-07T16:31:55Z")

</div>

Hi Ava,  
according to the class definition:[UserSearchService (Atlassian JIRA 7.1.9 API)](https://docs.atlassian.com/software/jira/docs/api/7.1.9/com/atlassian/jira/bc/user/search/UserSearchService.html#findUsers-com.atlassian.jira.bc.JiraServiceContext-java.lang.String-)

> If the users in the database change during this call results might not be consistent if a [post processing filter](https://docs.atlassian.com/software/jira/docs/api/7.1.9/com/atlassian/jira/bc/user/search/UserSearchParams.html#getPostProcessingFilter--) and a result limit is used.

I don’t see any limits set in the script. My test env jira does not have that many users.  
My console run returns all 256 users. But to speed up execution I’ve removed call to a function deactivateUser().

Once I’ve had similar experience with script runner console. It was hanging on processing bulk data. I think it was Issue.Update. I’ve ended up feeding list of issue id’s to the script in batched chunks via file system.  
Have you checked Jira log? Is there any warning on execution termination and timeouts?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/adaptavistlibrary/original/1X/ceb18adf14fa58b4c6de03aa69ada8b07359620c.png) [@system](https://forum.library.adaptavist.com/u/system)\
**Post date:** [July 6, 2025, 4:32pm UTC](https://forum.library.adaptavist.com/t/deactivating-idle-users-after-custom-period-script-is-not-finding-all-idle-users/548/3 "2025-07-06T16:32:52Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
