File tree 3 files changed +16
-10
lines changed
3 files changed +16
-10
lines changed Original file line number Diff line number Diff line change 3
3
4
4
user=$1
5
5
uid=` id -u`
6
+ cgroupdir=/sys/fs/cgroup/memory
7
+ testdir=test
6
8
7
9
if [ $uid != 0 ]
8
10
then
9
11
echo " Need to be root"
10
12
exit
11
13
fi
12
14
13
- if [ ! -d /sys/fs/cgroup/memory ]
15
+ if [ ! -d $cgroupdir ]
14
16
then
15
17
echo " Non-standard cgroup configuration"
16
18
exit
17
19
fi
18
20
19
- mkdir /sys/fs/cgroup/memory/test
20
- echo 1M > /sys/fs/cgroup/memory/test /memory.limit_in_bytes
21
+ mkdir $cgroupdir / $testdir
22
+ echo 1M > $cgroupdir / $testdir /memory.limit_in_bytes
21
23
22
- chown -R $user /sys/fs/cgroup/memory/test
24
+ chown -R $user $cgroupdir / $testdir
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
3
+ cgroupdir=/sys/fs/cgroup/memory
4
+ testdir=test
3
5
curr_user=` id | cut -d " (" -f 2 | cut -d " )" -f 1`
4
6
5
7
echo $curr_user
6
8
7
9
echo " Now we need root"
8
10
sudo ./setup-cgroups.sh $curr_user
9
11
10
- echo $$ > /sys/fs/cgroup/memory/test /tasks
12
+ echo $$ > $cgroupdir / $testdir /tasks
11
13
12
14
echo " Now we are trapped in the correct cgroup"
13
15
cat /proc/self/cgroup | grep memory
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
3
3
uid=` id -u`
4
+ cgroupdir=/sys/fs/cgroup/memory
5
+ testdir=test
4
6
5
7
if [ $uid != 0 ]
6
8
then
7
9
echo " Need to be root"
8
10
exit
9
11
fi
10
12
11
- if [ ! -d /sys/fs/cgroup/memory ]
13
+ if [ ! -d $cgroupdir ]
12
14
then
13
15
echo " Non-standard cgroup configuration"
14
16
exit
15
17
fi
16
18
17
- if [ ! -d /sys/fs/cgroup/memory/test ]
19
+ if [ ! -d $cgroupdir / $testdir ]
18
20
then
19
21
echo " Cgroups not setup"
20
22
exit
21
23
fi
22
24
23
- for pid in ` cat /sys/fs/cgroup/memory/test /tasks`
25
+ for pid in ` cat $cgroupdir / $testdir /tasks`
24
26
do
25
- echo $pid > /sys/fs/cgroup/memory /tasks
27
+ echo $pid > $cgroupdir /tasks
26
28
done
27
29
28
- rmdir /sys/fs/cgroup/memory/test/
30
+ rmdir $cgroupdir / $testdir
You can’t perform that action at this time.
0 commit comments