# How does the scheduler find the primary group?

**URL:** <https://community.openpbs.org/t/how-does-the-scheduler-find-the-primary-group/4221>\
**Category:** Users/Site Administrators\
**Created:** [March 11, 2026, 7:06pm UTC](https://community.openpbs.org/t/how-does-the-scheduler-find-the-primary-group/4221 "2026-03-11T19:06:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgasp](https://avatars.discourse-cdn.com/v4/letter/m/3be4f8/32.png) [@mgasp](https://community.openpbs.org/u/mgasp)\
**Post date:** [March 11, 2026, 7:06pm UTC](https://community.openpbs.org/t/how-does-the-scheduler-find-the-primary-group/4221/1 "2026-03-11T19:06:26Z")

</div>

How does the scheduler find the primary group? I have a user (Adam) who is a member of multiple groups:  
adama (primary group when using `id` to check group membership)  
GroupA  
GroupB

GroupC

….

GroupX

GroupY

GroupZ

We use `newgrp` to switch primary groups in the current session, this is due to the 16-group NFS limitation, and us needing to maintain per-group access control. For the sake of this question, this cannot be changed (i.e. no manage-gids, NFSv4, etc.)

So when Adam submits a job, his group in the session is `GroupA`, but when the job runs, it runs under `adama`. The workaround to set the group under which a job runs is `-W group_list`, but i wanted to see:

1. If there’s another way to get PBS to respect the group at job submission time.
2. Use a hook / wrapper to set `-W group_list` automatically

---

<div class="post-metadata">

**Author:** ![adarsh](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@adarsh](https://community.openpbs.org/u/adarsh)\
**Post date:** [March 12, 2026, 8:07am UTC](https://community.openpbs.org/t/how-does-the-scheduler-find-the-primary-group/4221/2 "2026-03-12T08:07:29Z")

</div>

The discussion on this page might be helpful

> [@Hook to put a job in a queued based on user egroup](https://community.openpbs.org/t/hook-to-put-a-job-in-a-queued-based-on-user-egroup/2531):
>
> Hello guys, how are you doing? I’m trying to write a hook to check the user’s group parameter. If the user belongs to the “others” group, the job is moved to a specific queue (eg. test) regardless of which queue he has specified. I’m using the Hook Book as a reference, but I don’t have much knowledge in python and I’m unsure of which instruction to use on the hook to change the job’s queue . I wrote, this simple script: import sys import pbs try: e = pbs.event() j = e.job pbs.l…

> <https://github.com/openpbs/openpbs/blob/master/src/resmom/start_exec.c>

Check this: getpwnam()

Hook and wrapper scripts are the way to go.
