# Can I pass in arbitrary attributes to a job?

**URL:** <https://community.openpbs.org/t/can-i-pass-in-arbitrary-attributes-to-a-job/2492>\
**Category:** Users/Site Administrators\
**Created:** [February 12, 2021, 8:45pm UTC](https://community.openpbs.org/t/can-i-pass-in-arbitrary-attributes-to-a-job/2492 "2021-02-12T20:45:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![weallcock](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/weallcock/32/466_2.png) [@weallcock](https://community.openpbs.org/u/weallcock)\
**Post date:** [February 12, 2021, 8:45pm UTC](https://community.openpbs.org/t/can-i-pass-in-arbitrary-attributes-to-a-job/2492/1 "2021-02-12T20:45:48Z")

</div>

We are switching from another scheduler to PBS. Previously we had the ability to pass arbitrary attributes into the scheduler. As an example for why, on our clusters, by defaul,t external interfaces are down. Very few jobs use them and there is no sense leaving an external conduit open for BAD™ people to target. We had defined a custom attribute called pubnet. If a user added --attrs=pubnet to their qsub then we would up the interfaces in the job prolog and then down them again in the epilog. I tried #PBS -W pubnet and #PBS -W pubnet=true. AFAICT, you can only pass attrs that PBS knows about, like umask. I don’t believe environment variables will do what we want. We want access to this in the hooks, not in the jobs environment. Is there any way I can get arbitrary attributes from the users command line into a hook?

I would appreciate any ideas anyone has.

Thanks,

Bill

---

<div class="post-metadata">

**Author:** ![agrawalravi90](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@agrawalravi90](https://community.openpbs.org/u/agrawalravi90)\
**Post date:** [February 12, 2021, 9:37pm UTC](https://community.openpbs.org/t/can-i-pass-in-arbitrary-attributes-to-a-job/2492/2 "2021-02-12T21:37:15Z")

</div>

Hi Bill,

Did you look into custom resources? AFAIK, you are correct, PBS doesn’t allow you to add custom attributes, we add “custom attributes” via resources instead. Please check out the Custom Resources section of the admin guide (for 2020.1, it’s Chapter 5.14) and let us know if they might serve your use case.

Thanks,  
Ravi

---

<div class="post-metadata">

**Author:** ![weallcock](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/weallcock/32/466_2.png) [@weallcock](https://community.openpbs.org/u/weallcock)\
**Post date:** [February 12, 2021, 10:17pm UTC](https://community.openpbs.org/t/can-i-pass-in-arbitrary-attributes-to-a-job/2492/3 "2021-02-12T22:17:20Z")

</div>

Yes, of course. That should work just fine and I should have thought of it ☹ . When all you have is a hammer, everything looks like a nail, so I was looking for an attr, which is nothing more than a string, which is also what a custom resource is. Thanks for the whack upside the head 🙂 .

Regards,

Bill

---

<div class="post-metadata">

**Author:** ![Source](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/source/32/756_2.png) [@Source](https://community.openpbs.org/u/Source)\
**Post date:** [October 21, 2024, 7:51am UTC](https://community.openpbs.org/t/can-i-pass-in-arbitrary-attributes-to-a-job/2492/4 "2024-10-21T07:51:21Z")

</div>

Did you try to read j.Variable\_List in a hook? i didnt test it but i believe you could read the environment variables there from the job within a hook.  
Another way just add a custom resource, and throw all your information to it use some kind of serialization, e.g base64 encoded json, then you could theoretically grab everything. Add one custom resource once for all.

---

<div class="post-metadata">

**Author:** ![speleolinux](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@speleolinux](https://community.openpbs.org/u/speleolinux)\
**Post date:** [October 22, 2024, 4:29am UTC](https://community.openpbs.org/t/can-i-pass-in-arbitrary-attributes-to-a-job/2492/5 "2024-10-22T04:29:31Z")

</div>

Hi  
Ravi is spot on. You can add a string resource with a default value that users can override if they need to. We had to do that with a host level resource called “intel\_node” as some of our nodes were AMD and not Intel and at the time didn’t support the avx2 instructions.  
Sorta like this:  
head node $ qmgr -c ‘create resource intel\_node type=string\_array,flag=h’  
Then also add it to the resources line of /var/spool/pbs/sched\_priv/sched\_config so its listed along with ncpus and mem etc.  
Then I used a short bash script to set it how I wanted it for particular nodes:  
for n in 01 02 03 04 14 15 16 17 18 19 20 21 22 23; do  
node=“node${n}”  
qmgr -c “set node $node resources\_available.intel\_node=yes”  
done  
Then HUP the scheduler.  
Note: This was done on an older PBSPro installation so might be a bit different to this later OpenPBS version.

Mike
