Ubuntu – ‘Singleton’ application – or let the user only launch one instance of a program at the time

gnomeUbuntu

I'm running a few linux desktops; mainly for kids (yeah, trying to teach them the right OS at early stage) (running Ubuntu 10.10, Gnome)

The problem is that they found very funny to make their workstations (actually, old 512 Mb pentium 4) by launching thousands of firefox instances.

I'm looking for a way to restrict them to launch 'N' instances of a particular application. Haven't figured yet how. Thought of a monitoring daemon but I think that would be too ressources hungry.

Any idea of a script/trick to achieve this ?

Note: i might have 1-2 level of users (the kids, and the more grown up kids) so i have also to limit per user; something like user1: 3firefox, user2: 2firefox instances.

Best Answer

It seems like your issue is that too many programs are able to be launched, not that there are too many of one app or another. For that, you might want to look into better process limiting/throttling so that they can't crash the machine that way.

As far as prevention with specific apps: When dealing with kids, what I would do is look into making shortcuts that open the current running instance of an app if there is one already open, and opens another only if there isn't. Or simply don't work if there's already a running instance.

You can make shortcuts that use a command from the command line instead of whatever they're currently doing. I can't recommend a specific command syntax that just doesn't work if there's already an instance running, but that's where I would start looking.

Related Topic