Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I would like to be able to create a one-time temporary group in hierarchy. For example:

#!/bin/sh
run_with_csubgroup /sys/fs/cgroup/group/subgroup/

Which creates group say /sys/fs/cgroup/group/subgroup/5G7ds/ (5G7ds is one-time name - it might be ID or anything).

I would like to delete the group automatically but I don't know how to do it easily and prone to say TERM signal (from actidental C-c).

Is there a way to do it? I'm using Gentoo+systemd.

share|improve this question
    
Are you sure you really need to create a temporary group? –  tiktak Mar 28 '12 at 12:17
    
@Mathieu: I don't need to create a temporary group but I have a set of tasks which contains various processes (each takes a few minutes to few hours). I want (not need) them to compete in scheduler as a whole rather then as separate processes. –  Maciej Piechotka Mar 28 '12 at 15:48
    
You can use trap to react on signals. Does not solve the question re. cgroups but may help re. capturing ctrl-c –  Ulrich Dangel Jun 11 '12 at 21:09

2 Answers 2

You may need to specify a specific lifetime for your group; you may want it on after computer startup and deleted after shutdown. So it's not a bad idea to add it to your /etc/rc scripts .

share|improve this answer

Not sure I understand correctly, but can't you just:

~] umount /sys/fs/cgroup/group/subgroup/5G7ds/
~] rmdir /sys/fs/cgroup/group/subgroup/5G7ds/

The above unmounts the cgroup and removes it.

share|improve this answer
1  
I would like to have it automated. I.e. a group which 'autodestructs' when there is no tasks to it (in similar way as inode is freed after there is no entries pointing to it). –  Maciej Piechotka May 16 '12 at 6:28
1  
The easiest solution that comes to mind is just checking whether a tasks file in a given cgroup is empty and if it is, run the above commands. You can set it up as a cron job that executes every 10 minutes and cleans up any "unused" cgroups. –  mart1n Jun 5 '12 at 17:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.