Visokio website     Downloads     Video tutorials     KnowledgeBase  
Scheduler: Execute Command Action - Visokio Forums
Scheduler: Execute Command Action
  •     neilmerchant June 16, 2011 7:42AM
    Hi - I am trying to run the following command in the Execute Command Action option but it always hangs on the following command. The idea is to get the Scheduler to sit in a loop and wait for a file to exist. if the file does not exist I want to pause for 1 minute and then check again. However stripping the code down and testing each line it is the sleep function that does not work:-

    choice /c 1 /d 1 /t 60 >nul

    Any other ideas on how to fix this or how I can make it wait for a file to exist?
    Regards, Neil
  • 9 Comments
  •        mohamed June 17, 2011 11:46AM
    Hi Neil,
    You could use the watch folder to do this "http://www.visokio.com/kb/watch-folder". This means that all your clients files should come with an XML action descriptor file that describes what the scheduler should do. This is the easiest approach to do this and you do not have to write commands. Please let me know if this solution suffices.
  •     neilmerchant June 17, 2011 11:57AM
    Hi Mohamed
    We are doing this at the moment but there are 2 reasons we wanted to do this. The other one is to use this to find out when a job has finished on the scheduler. For example we have one big job that runs then we want to be able to run about 5-10 other jobs using the fork execution at the same time when this first job is done. I know we can add these all to the same schedule but we want to get the data out faster than that, plus if one fails at the top the rest of the jobs don't run.
    We don't want these jobs to kick off until the first is done. I know I can do it with the watch folder, I just think it will be tidier using a script and getting the job to wait until the trigger is ready. Rather than coping 10 xml's over in one go.
    Will the watch folder run 10 jobs at once if 10 xml's are dropped in the folder at the same time and fork is on?
    Regards
    Neil
  •        mohamed June 17, 2011 1:04PM
    Hi Neil,
    The following batch file checks for any IOK files in a specific directory. If there is no IOK file it will keep checking, until an IOK file is found.

    The batch file is as follows:

    "
    :LoopStart
    IF EXIST "C:\Users\[User home]\Batch\*.iok" GOTO LoopEnd
    echo 'sleeping for 2 secs'
    sleep 2
    GOTO LoopStart
    :LoopEnd
    REM You're out of the loop now
    echo 'File exists'
    "
    Please configure the scheduler Execute command action to execute the above batch file.

    The following tasks will only execute if an IOK file exists in the given directory.
  •     neilmerchant June 17, 2011 1:35PM
    HI Mohamed
    "Sleep" doesn't work with Windows Server 2008 - I already tried :(
    N
  •        mohamed June 17, 2011 2:05PM
    Could you please try this command "choice /d y /t 2 > nul" instead of sleep.

    I found this command in the following page "http://serverfault.com/questions/38318/better-way-to-wait-a-few-seconds-in-a-bat-file".
  •     neilmerchant June 20, 2011 5:29AM
    Hi Mohamed
    I have tried every single one of those, either now or on other site I found before and none seem to work. Its as if the Scheduler doesn't like anything that waits. Its odd that it doesn't like the ping one as they does not wait!
    Regards, Neil
  •        mohamed June 20, 2011 5:44AM
    Could you please send me your Scheduler configuration file. It could be the way you are scheduling the tasks?
  •        mohamed June 20, 2011 1:47PM
    Please test using the following batch file and replace your existing batch file completely with this one.

    "

    :LoopStart

    REM Do something

    REM Break from the loop if a condition is met

    IF EXIST "I:\Job\trigger.iok" GOTO LoopEnd

    REM Iterate through the loop once more if the condition wasn't met

    echo 'sleeping for 2 secs'

    sleep 2

    GOTO LoopStart

    :LoopEnd

    REM You're out of the loop now

    echo 'File exists'

    "

    I have carried out various tests on Windows 7 and Window server 2007 and it works without problems.
  •     mustafa October 3, 2011 9:57AM
    For the benefit of other users, there is now a scheduler task that allows you to "Wait for a file".

Welcome!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership