[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Condor-users] Only run when logged of?

I came up with the following script

trComputer = "."   ' " use "." for local computer 

Set objWMI = GetObject("winmgmts:" _ 
           & "{impersonationLevel=impersonate}!\\" _ 
           & strComputer & "\root\cimv2")
Set colSessions = objWMI.ExecQuery _ 
  ("Select * from Win32_LogonSession Where LogonType = 2") 
If colSessions.Count = 0 Then     
  Wscript.Echo "FALSE" 

  WScript.Echo "True"
End If

So this echos TRUE is a user is Logged on and False is not. My questions is though when you say it must return TRUE or FALSE to the STARTD_CRON job I am assuming I would need to change the echo statements but I am not sure what to. 

Any ideas. Other wise this seems a perfect solution. 



Date: Wed, 15 Sep 2010 10:31:10 -0400
From: ichesal@xxxxxxxxxxxxxxxxxx
To: condor-users@xxxxxxxxxxx
Subject: Re: [Condor-users] Only run when logged of?

On Wed, Sep 15, 2010 at 8:48 AM, Dave STREET <davey_street@xxxxxxxxxxx> wrote:
I am sure this is easy and I know some people do it, but how can I make it so windows machines only accept jobs and run jobs while no one is logged on, and remove jobs as soon as a user logs in? 

I can see how to set up for CPU and keyboard busy. But I want to have the logged on status of the machine control when jobs can and cant run? 


There isn't a built-in macro in Condor that indicates whether a user is logged in to a machine or not. But you could write something that can be called from a STARTD_CRON that returned True or False depending on whether users are logged in or not.

And then:

STARTD_CRON_LOGINCHECKER_EXECUTABLE = c:\condor\loginchecker.exe

(That syntax is likely not 100% correct, I'm working from memory here on the cron syntax, but that should get you started)

The output from loginchecker.exe should be ClassAd attribute syntax. So:

UsersLoggedIn = (True|False)

That'll produce an attribute in your machine's ad called LoginCheckerUsersLoggedIn that you can reference in your START/SUSPEND/PREEMPT strings:

START = $(LoginCheckerUsersLoggedIn) =!= True

That should also keep START = False if the cron hasn't run and the attribute has never been set.

- Ian

Cycle Computing, LLC
The Leader in Open Compute Solutions for Clouds, Servers, and Desktops
Enterprise Condor Support and Management Tools


_______________________________________________ Condor-users mailing list To unsubscribe, send a message to condor-users-request@xxxxxxxxxxx with a subject: Unsubscribe You can also unsubscribe by visiting https://lists.cs.wisc.edu/mailman/listinfo/condor-users The archives can be found at: https://lists.cs.wisc.edu/archive/condor-users/