Go Back   The macosxhints Forums > OS X Help Requests > Applications



Reply
 
Thread Tools Rate Thread Display Modes
Old 05-13-2009, 03:10 AM   #1
jeno
Prospect
 
Join Date: May 2009
Posts: 8
AppleScript to quit application if idle

Hello All,

I am very new to AppleScript and hope to get some advice. I want to write a AppleScript to quit an application if leaving it idle for 15 minutes. Please also note that the computer may not be in idle. Is it possible only to get idle time for application?

In live situation, it works something like this: I am working on my mac and I have a few applications open. I want the script to quit/force quit the application that I leave it for 15 minutes. Similarly I want to do the same with mounted network drive. I want to disconnect network drive if leaving them idle for 15 minutes.

Please help.

Thanks & Regards,
Jeno
jeno is offline   Reply With Quote
Old 05-13-2009, 09:44 AM   #2
benwiggy
MVP
 
Join Date: Aug 2006
Posts: 2,281
Can I ask why you want to quit idle apps? What's your objective?
benwiggy is offline   Reply With Quote
Old 05-14-2009, 12:09 AM   #3
jeno
Prospect
 
Join Date: May 2009
Posts: 8
Over the time, I had try to educate the user at my company to always save their work close the application that they do not need to use anymore. Users always complaining that their workstation are slow even if they are using the best and fully loaded Mac Pro.

There are times where I am getting very frustrated and even want to slap them on their face. Now that it is proven that "nice education" doesn't work. I am going to write a script to force quit/disconnect any application and server. I have done a search on this forum and understand that this is not a good/healthy way, but user need to get educated, I doesn't really care if user lost their work and it doesn't do much damaged to the application itself. I need a way to forcing user to adopt a good habit of always saving job and close down the apps.

Thanks & Regards,
Jeno
jeno is offline   Reply With Quote
Old 05-14-2009, 12:22 AM   #4
fazstp
MVP
 
Join Date: May 2004
Location: Melbourne, AUS
Posts: 1,415
Sounds like a bad idea. If they lose work because you force-quit an application surely that is worse than a workstation being a bit slow? If the slowness of the workstations is due to poor work habits then I would say step up the education but force-quitting apps is going to create some bad workplace relations.

Sorry, I know you asked for a script not an opinion. Just my 2c.
__________________
:')
fazstp is offline   Reply With Quote
Old 05-14-2009, 12:24 AM   #5
hayne
Moderator
 
Join Date: Jan 2002
Location: Montreal
Posts: 29,452
Quote:
Originally Posted by jeno
Users always complaining that their workstation are slow even if they are using the best and fully loaded Mac Pro.

And what evidence do you have that the slowness (real or apparent) is due to having extra apps running that aren't being used? (This doesn't seem like a likely reason for slowness.)

Quote:
user need to get educated, I doesn't really care if user lost their work and it doesn't do much damaged to the application itself. I need a way to forcing user to adopt a good habit of always saving job and close down the apps.

So in order to "educate" your users, you are going to make them lose some data (things they have worked on but not yet saved) ?!?

Not a good idea.
What exactly is your higher level goal? Are you trying to help the users? Or just stop them from complaining? Or just exert control because you think you should?
__________________
hayne.net/macosx.html
hayne is online now   Reply With Quote
Old 05-14-2009, 03:03 AM   #6
tw
Hall of Famer
 
Join Date: Apr 2007
Posts: 3,342
there are much better options here than forcing users to quit their apps. if these are multi-user (public) workstations, redesign your system so that users have to log in and out (maybe with a timer that pops up after 10 minutes of system inactivity and logs them out if they don't respond). that will prevent users from leaving files open on the machine. If these are workstations for individuals, let them do what they want. write an FAQ about using computer resources efficiently, and point anyone who complains to that FAQ.
__________________
Philosophy is a battle against the bewitchment of our intelligence by means of language. -LW-
tw is offline   Reply With Quote
Old 05-14-2009, 03:03 AM   #7
benwiggy
MVP
 
Join Date: Aug 2006
Posts: 2,281
Quote:
Originally Posted by jeno
Over the time, I had try to educate the user at my company to always save their work close the application that they do not need to use anymore. Users always complaining that their workstation are slow even if they are using the best and fully loaded Mac Pro.

If the Macs are fully loaded with RAM, then having idle apps is probably not the cause of the slowness.
Might it be something else? Network accounts?
benwiggy is offline   Reply With Quote
Old 05-14-2009, 04:31 AM   #8
jeno
Prospect
 
Join Date: May 2009
Posts: 8
I totally understand but apparently the bad user habit has causes the OS or application to crashed most of the time and it happen regularly. This is where I get idea of writing a script to "simulating" the "crash".
jeno is offline   Reply With Quote
Old 05-14-2009, 04:53 AM   #9
benwiggy
MVP
 
Join Date: Aug 2006
Posts: 2,281
What is the bad habit that the users have? Leaving apps open is not a bad habit.
Even so, why would you want to simulate a crash: to help your users learn not to cause crashes....?

What do the crash logs indicate might be the cause of the crashes, both for the apps and the OS?
benwiggy is offline   Reply With Quote
Old 05-14-2009, 05:14 AM   #10
jeno
Prospect
 
Join Date: May 2009
Posts: 8
Education is definitely not going to work. Can anyone please advice me a better way to get this done?

Cheers,
jeno is offline   Reply With Quote
Old 05-14-2009, 05:26 AM   #11
jeno
Prospect
 
Join Date: May 2009
Posts: 8
Maybe I explained it wrong from thee beginning. The main issue is that I am limited to a certain # of license software plug-in Apps. for Illustrator. Every computer has the software plug-in app installed, but I only have a finite # of licenses. When a user logs into the plug-in, does the task at hand, the plug-in remains active. That causes myself and my IT staff to walk around to all of the computers and see who is idle but still connected to thee plug-in. This is what I am looking for and to see if it is possible to write a script that sits in the background, instead of looking at each computer through Apple Remote desktop and see that way. Thanks
jeno is offline   Reply With Quote
Old 05-14-2009, 09:02 AM   #12
tw
Hall of Famer
 
Join Date: Apr 2007
Posts: 3,342
Quote:
Originally Posted by jeno
Maybe I explained it wrong from thee beginning. The main issue is that I am limited to a certain # of license software plug-in Apps. for Illustrator. Every computer has the software plug-in app installed, but I only have a finite # of licenses. When a user logs into the plug-in, does the task at hand, the plug-in remains active. That causes myself and my IT staff to walk around to all of the computers and see who is idle but still connected to thee plug-in. This is what I am looking for and to see if it is possible to write a script that sits in the background, instead of looking at each computer through Apple Remote desktop and see that way. Thanks

That's confusing. software licenses are for the installation, not the use: if you have 12 machines and 3 licenses that means you can install the app on 3 machines. installing it on all 12 is illegal, even if no one ever uses it.

at any rate, my advice would be the same: pick 'x' machines (one for each license that you own); install the app on those and remove it from the others, and then make it so people have to log in and log out to use those machines.
__________________
Philosophy is a battle against the bewitchment of our intelligence by means of language. -LW-
tw is offline   Reply With Quote
Old 05-14-2009, 09:41 AM   #13
hayne
Moderator
 
Join Date: Jan 2002
Location: Montreal
Posts: 29,452
Quote:
Originally Posted by tw
software licenses are for the installation, not the use

No - it is quite common to have "floating licences" where you can install the software on as many machines as you want, but only a specified number can use the software at a given time - usually controlled by a licence server on the network. It would seem that this is the situation jeno has.
__________________
hayne.net/macosx.html
hayne is online now   Reply With Quote
Old 05-14-2009, 09:45 AM   #14
hayne
Moderator
 
Join Date: Jan 2002
Location: Montreal
Posts: 29,452
Quote:
Originally Posted by jeno
Maybe I explained it wrong from thee beginning. The main issue is that I am limited to a certain # of license software plug-in Apps. for Illustrator.

Indeed it would have been a good idea to have explained the real problem from the beginning. Now it is clear.

Since the problem seems to be related to one particular application, it seems that you could just monitor that one app (e.g. with a background script that looks at the CPU time used by that app) and pop up a dialog asking the user to quit the app if it hasn't been used for a while.

You can get info on CPU usage via the 'ps' command.
__________________
hayne.net/macosx.html
hayne is online now   Reply With Quote
Old 05-14-2009, 10:40 AM   #15
NovaScotian
Hall of Famer
 
Join Date: Oct 2002
Location: Halifax, Canada
Posts: 3,517
Quote:
Originally Posted by hayne
No - it is quite common to have "floating licences" where you can install the software on as many machines as you want, but only a specified number can use the software at a given time - usually controlled by a licence server on the network. It would seem that this is the situation jeno has.

This is precisely the way in which limited licenses for expensive image editing and CAD software were controlled at the university from which I'm retired. A network server controlled that and it did indeed monitor usage because students would often run a limited app just to save their access to it later. The server had a "Use It Or Lose It" script, too, that started with a 10-minute warning and ended with a shutdown of the software.
__________________
PPC dual-core G5/2.3, OS X 10.5.8; 17" MBP Core 2 Duo/2.6, OS X 10.6.2; VMWare Fusion->Win XP
NovaScotian is online now   Reply With Quote
Old 05-14-2009, 12:33 PM   #16
tw
Hall of Famer
 
Join Date: Apr 2007
Posts: 3,342
Quote:
Originally Posted by hayne
No - it is quite common to have "floating licences" where you can install the software on as many machines as you want, but only a specified number can use the software at a given time - usually controlled by a licence server on the network. It would seem that this is the situation jeno has.

well, what an odd way of doing things. if that's the way it works, though, then there's a couple of approaches to the problem:
  • have each machine run a script that checks to see how long an app has been idle and quit it if it's over a certain limit
  • have a central machine run a script over the network to see how many versions are running and force quit idle apps if there are more than the allotted share (and maybe disable machines from launching new instances if the limit is reached)
There's also the question of what the best way to check for idle processes is, particularly since the 'nix conception of idling is computer-centric - 20 seconds - while the human conception of idling is probably closer to 15 minutes. how would you get ps (or top, or come other process) to calculate how much action an app has gotten in the last 15 minutes? I'm not sure CPU use will cut it (microsoft Word, for instance, consistently uses 8-12% of my CPU, foreground or background). is there a way to check to see if the app is (or has been) the active app in the last X minutes?
__________________
Philosophy is a battle against the bewitchment of our intelligence by means of language. -LW-
tw is offline   Reply With Quote
Old 05-14-2009, 01:56 PM   #17
NovaScotian
Hall of Famer
 
Join Date: Oct 2002
Location: Halifax, Canada
Posts: 3,517
Back in the days I was talking about (now 7 years ago), Novell had server software for managing limited licenses in exactly the way you're describing. I don't know how the software measured "idle" time, but we didn't get complaints so it worked. Bear in mind, however, that the limited license software was not entirely on the user's machine, it was netware. I don't know the details, unfortunately (I was the Dean of the Faculty, not the IT guy).
__________________
PPC dual-core G5/2.3, OS X 10.5.8; 17" MBP Core 2 Duo/2.6, OS X 10.6.2; VMWare Fusion->Win XP
NovaScotian is online now   Reply With Quote
Old 05-14-2009, 11:34 PM   #18
jeno
Prospect
 
Join Date: May 2009
Posts: 8
Hello,

Any luck helping me getting this done?
jeno is offline   Reply With Quote
Old 05-15-2009, 09:20 AM   #19
NovaScotian
Hall of Famer
 
Join Date: Oct 2002
Location: Halifax, Canada
Posts: 3,517
I can't believe there isn't software available to do it.
__________________
PPC dual-core G5/2.3, OS X 10.5.8; 17" MBP Core 2 Duo/2.6, OS X 10.6.2; VMWare Fusion->Win XP
NovaScotian is online now   Reply With Quote
Old 05-15-2009, 09:43 AM   #20
tw
Hall of Famer
 
Join Date: Apr 2007
Posts: 3,342
Quote:
Originally Posted by jeno
Any luck helping me getting this done?

Jeno, read my last post and answer the questions. and at least tell us what application you're talking about. is it illustrator itself you want to quit, or a particular plugin?
__________________
Philosophy is a battle against the bewitchment of our intelligence by means of language. -LW-
tw is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 11:06 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Site design © Mac Publishing LLC; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of Mac Publishing LLC.