Kill hudson-job after time-range - time

I am right now evaluating Hudson. Unfortunately I came across some problems with our test scripts. Which freezes the execution of the job.
I am running an UI-Test. This test waits for a Widget and if the Widget is not there, it keeps waiting and waiting and waiting and wai...
Now I want to run the Job every day, and if it should freeze, I want to kill it after 23 hours, so that the daily test will not be holded in the build-queue.
Is there a plugin/script/anything to do this? Basically in my thoughts there should be a script which analyses the starting time and if now()-startTime >= 23 hours the job should be killed/cancelled/stopped.
Thanks in advance,
Stefan

There is a Build Timeout plugin for Hudson which should to what you want.

Related

Windows Task Scheduler wont start task because it thinks previous version is still running

I have an occasional problem (maybe twice a month) were windows task scheduler won't start a new task because it thinks the old version is still running.
The task is a powershell script, it runs all day, every day. The task scheduler starts the script at 5 past midnight every day (UTC), and then the scripts exits itself everyday at 23:55 (UTC). The script does the following actions.
logs its own startup in a database
spends all day reading records from a remote server.
logs its own shutdown at 23:55 every night and exits with 'exit 0'
Task scheduler runs the script with the -NoExit option, so the powershell console remains open on the screen even after the task has exited (allowing a visual check of any output generated)
This all works fine 95% of the time, however, occasionally when the task scheduler attempts to start the new task at 00:05 I see the message 'Launch request ignored, instance already running' in the history. But when I check the log records from the powershell script I see that it started and finished at it's normal time, and I can double check this against the console.
Curiously, on these occasions the task scheduler history indicates that the blocking task finished at about 8am - a time which always corresponds to when I logged on that day.
Any suggestions on what's going wrong and how to sure it? I've already tried tweaking some of the task settings "if the task is already running then the following rule applies - stop the existing instance" but because the fault is intermittent, it's very hard to pin down.
Update - following further testing.
I've tried creating 100s of similar tasks and running them with similar conditions. So far I've reached two conclusions, firstly everything seems to work OK if I remove the -NoExit option. It's almost as if the scheduler has trouble differentiating between the command window, and the PowerShell script itself.
Secondly, everything seems to work ok if increase the gap between the previous schedule dying and the new one starting from about 15 minutes to half an hour or longer. It's as if the task scheduler takes time to work out that the old task has stopped.

resume timing in task scheduler?

i am trying to make a program run for 13 hours every 7 days and then the program will stop and the task will end. However i may turn off my computer during that time and then do you know if when i start the task again the timer will resume?
for example
i start my task it runs for 5 hours i then turn off my computer.
next day i turn my computer on and the task starts and runs for 8 hours
then...
will the task end becasue it has reached 13 hours or will it continue to run till it reaches 13 hours?
is there a way to make the timer resume whenever i turn my computer off or do you know of any program that will do this
any help would be appreciated thanks
To some degree, it depends on the operating system your computer or mobile device runs. If you are running Windows 2000+ or a UNIX derivative (Linux, BSD, OSX), we have use of tools like cron to start us off. If it's a mobile device, we have a bit more work to do.
I'll assume you have a Windows or UNIX device to start. Therefore, you have the Startup/init.d layers of the OS to kick things off when you begin. This is used just to fire things off at power up. We might, for example, write a shell script/WSH script that, at login/startup, runs your up. At this point, you are running, but we want to do a bit more.
Since your app can now be started by the system, we need to make sure it stays running and is restarted if necessary, even if the system is not rebooted. For example, it could be killed/terminated by other events. Our goal is to start your script up at system start, and ensure it runs for 7 hours. Assuming UNIX/Linux:
This can be done with two tasks:
One task just ensures that we've run at least every seven days
The other task ensures when we run, we run for seven hours and no more.
Our first task is a pair of cron scripts. One runs ever 30 minutes. It's sole task is to check to ensure the main worker task is either running or finished. If it's not finished, and it's not running for some reason, start it. The second cron task runs every seven days and when run, cleans up the markers from the worker task.
Our main worker task, when run, splits its workload into 30 minute segments. It runs each segment, and leaves a "breadcrumb" in temporary storage somewhere -- basically, it says "I've done another 30 minutes of work". When it has 14 crumbs, it's done.
How this all works:
Cron or init.d starts up the main worker thread
THe worker thread runs, hopefully to 14 "chunks of work" and terminates.
Each week, the other cron tasks check to see if we had 14 chunks. If we did, it was a successful run. Remove them and start over. If not, restart the worker task.

Task Scheduler's has a task with a Next Run Time in the past

Creepy....
Anyone seen this before?
I can't think of anything I've done to cause this. Twice of the last two weeks, I've gone in to check on it, and I saw this.
Always try manually refreshing the view of your scheduled tasks. Even if you just opened Task Scheduler fresh.
I've found sometimes it's necessary for me to right click and choose refresh to see up to date information, even if Task Scheduler snap in was closed when I logged onto the machine.
I've just seen the same.
I have a task that has successfully run every morning for a number of months, except for the last couple of days.
Looking at the Task Scheduler (which I had open), the Next Run Time is a couple of days ago.
If I close and re-open Task Scheduler the Next Run Time corrects.
Maybe there is a problem with keeping Task Scheduler open?

Windows Task Scheduler will run app only once

So my situation is that I am running an app on the Windows Task Scheduler. This app is run once a day at 1pm. the app does some queries and transfers data to an FTP site. All that is working great except on the weekends when i am not here the app is run and the GUI is still displayed for me to review. This seems to make it stop running on the scheduler until I shut down the app. So on Saturday it will run and the app will remain displayed for me to review when I get back on Monday. but on Sunday when the scheduler attempts to run it again it will fail because the app has not been closed down.
First let me confirm that this is how the Task Scheduler is supposed to work. Second, what are my alternatives for scheduling to run every day and keep the GUI displayed so that I can review. The app can run multiple times as each session does not interfere with the other sessions. So if I'm gone for a week on vacation I would expect that when i get back that 7 instances of the app have been run and are waiting for my review.
Thanks
AGP
Your best bet is to eliminate the UI and log messages to the Event Log or a log file. The UI could be spawned from the CLI as a separate process if you prefer, but it should be done so in as its own non-child process.
Alternatively, you could run a batch file instead of the process directly. In the batch file, invoke "START path_to_exe" instead of the EXE. That will cause the batch file to "finish" instantly, and the exe to be run in its own process. This is not a good long term solution, but will give you a temporary solution to your immediate problem.
This is the default behavior of the Scheduled Task system, as it doesn't know that the job is complete until the application actually exits. Therefore, if your application is still open after 24 hours, the next run will simply be skipped because the current run is "still going" as far as the scheduler is concerned.
Personally I would re-visit the way that you handle your job process, as your are setting up a scenario that will be hard to manage long term.
I recommend writing to a log file instead of displaying a UI for any output and/or errors. This way, the application can write, then exit, and you can review the log at your convenience. This is a very common solution for automated processes.

How to run a windows scheduled task 20 mins after system startup?

In windows scheduled tasks properties, you can only choose "at system startup" without being able to assign a specific delay such as 20 minutes, so I wonder how can I setup a schedule task if I want it to run after the system "fully" starts up(you know how fast this can be in XP)? Hope you guys know the answer. Thanks
Create a scheduled task to run an app you've written, have the app you've written sleep for 20 minutes and then run the original app.

Resources