Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/scripts/smc-nice.py
Views: 275
1
#!/usr/bin/env python
2
import os, sys
3
4
passwd = [x.split(':') for x in open('/etc/passwd').readlines()]
5
6
7
def renice_user(user):
8
v = [x for x in passwd if user in x[2]]
9
if len(v) > 1:
10
print("user %s does not uniquely determine user" % user)
11
elif len(v) == 0:
12
print("no such user %s" % user)
13
else:
14
cmd = "sudo renice -n 19 -u %s" % v[0][0]
15
print(cmd)
16
os.system(cmd)
17
18
19
for user in sys.argv[1:]:
20
renice_user(user)
21
22