CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/scripts/smc-nice.py
Views: 687
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