LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-19-2008, 02:52 PM   #1
PB0711
Member
 
Registered: Aug 2004
Location: London, UK
Distribution: Ubuntu 10.10, ubuntu 11.04, suse 9.2, OSX
Posts: 259

Rep: Reputation: 30
prevent opening a program if running


Dear all,

Is there a way to prevent others running a program if the program is already running or if the program is running and doing calculations.
I have a box and my users keep logging in and running multiple instances of the program and the computer either dies or it just takes ages for everyones stuff to finish (and then they complain).

Is there a website to look at.
I was thinking I could use perl and top but how do I get top to not produce text constantly. And then how do I stop the user from logging in with Perl?

Thanks,

Paul

Last edited by PB0711; 05-19-2008 at 02:53 PM.
 
Old 05-19-2008, 07:42 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,707

Rep: Reputation: 2497Reputation: 2497Reputation: 2497Reputation: 2497Reputation: 2497Reputation: 2497Reputation: 2497Reputation: 2497Reputation: 2497Reputation: 2497Reputation: 2497
There are a few ways to achieve that:

1. use a lock file and have the prog check if lock file exists. If it does exit, prog is running, so new copy terminates immediately.
2. have prog use
ps -ef|grep <progname>
if prog name found, prog is running, etc
3. check the kernel files (/proc) and do as 2.

I prefer 2, 1 is not reliable if prog creashes, lock file is not removed, 3 is fiddly, but see Proc::ProcessTable::Process (search.cpan.org)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Having trouble opening a disk from program running in WINE mrzack Linux - Software 2 08-08-2006 12:52 AM
Firefox: prevent opening a new window evilmonkey Linux - Software 6 10-30-2004 12:50 PM
Segmentation Faults prevent program opening Elliott Linux - Software 3 09-15-2003 04:42 AM
Prevent users from running su Itzac Linux - Security 13 03-25-2003 05:25 PM
How to prevent X server from opening port 6000 glock19 Linux - General 5 05-23-2002 04:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration