KDB script keeps crashing - kdb

I've been finding recently that my KDB launch script is crashing. I need to restart my computer and then it will run fine. I launch KDB from a CMD prompt and I can't figure out where to look to see what process is running in the background which is causing it to crash. Does anybody know what I should check?
Thanks.

Trying running a blank kdb instance with just:
set QHOME=C:\q
set PATH=%PATH%;c:\q\w32
and then
q -p 1234
(doesn't need to be in a batch script, you should be able to just run those commands in a cmd prompt). If kdb comes up then kdb isn't the problem.
Then try to manually load the startup script to see if the problem is there:
q)system"l C:\\q\\ServerFiles\\server.q"
If this works fine then the problem isn't there. The last place it can be is in the database/directory load, so load that:
q)system"l c:\\q\\files"
If none of these cause an error then something else is affecting your kdb instance, either something running on a timer (check .z.ts) or something is connecting externally

So I did finally discover what the issue was. I had a few instances of KDB that would run via Task Scheduler in the evening and then close. One of the instances wouldn't end and so it was continually running. This would cause KDB to crash since there was already an instance running. The restart would stop the process so it could be run again. I deleted the task scheduler event and recreated it and now the event runs KDB and closes the way it is supposed to. Thanks for all of the help in trying to figure this out!

Related

Running Flask at startup as a Service in Windows won't work in background

Before explaining what my problem is, please know that I have looked up for solutions on similar topics but none of them seems to work nor even to corresponds to my problem.
What I am trying to do:
I have this python code on multiple files that I run with flask with the following command:
python -m flask run --host=0.0.0.0
So far, everything works, but I would like this code to automatically run everytime the computer boots. In the future this will be used on mini PCs without any graphical interface nor human intervention.
Since I need to do some configuration checks before running the web server, I've created a powershell script that ends with Flask running (using the previous command).
So far, everything works too. Now we're coming to the problem:
I'd like this script to run when I boot the machine. Specificity: Every things needs to work with Administrator privileges, on the local system without any interaction.
I've tried scheduled tasks but Flask won't run even if the rest of the script works (like creating folders or other things)
Ok, it's not a big deal I have other ways to do it, so I've created a Windows Service in C# to run the Script at startup on the local system.
The script works, I've checked the privileges too, everything's fine but arriving at the flask command line that is supposed to make it run, nothing works.
It's the same thing if I run flask using "pythonw" which is supposed to run python as a background process.
What the problem seems to be:
Well, as long as I run flask and I have either a command prompt or a powershell terminal, everything works greats. But if in a way or another I run the script as a background process, it won't work.
Normally it would take around 30 seconds for Flask to start-up. Here if I try to create a folder right after flask ended starting up (as a test) I can see the folder is created almost instantly, which means the process is immediately killed.
The problem doesn't seem to come from the service itself but really Windows that kills the process I don't know why
I'm running out of idea so if you guys have anything that I could try it would really help me.

Powershell Terminates After Few Seconds

Hi Stackoverflow Community,
I have a weird thing that is happening on my server. I was about to check if a certain script that is running okay on one of my servers on another server with same configuration. However, I realized that once I try to execute it, it will open for a time and start running only to terminate without finishing the whole script. Even doing a -noexit can't do anything about it and will immediately terminate the process without showing any error.
I tried to open Powershell console on its own without running any script, and guess what, still closes after a few seconds. Any idea why is this happening? Thanks!
All the best!

How to restart an exe when it is exits in windows 10?

I have a process in windows which i am running in startup. Now i need to make it if somehow that process get killed or stopped i need to restart it again in Windows 10?
Is there any way. Process is a HTTP server which if somehow stopped in windows i need to restart it. I have tried of writing a power-shell in which I'll check task-list status of process and then if not found I'll restart but that is not a good way. Please suggest some good way to do it.
I have a golang exe; under a particular scenario my process got killed or stopped i need to start it up again automatically. This has to be done imediately after the exe got killed. What is the best way to achieve this?
I will give you a brief rundown. You can enable Audit Process Termination in local group policy of the machine as shown below. In your case, success audits would be enough. Please note that the pic is for Windows 7. It may change with OS.
Now every time a process gets terminated, a success event will be generated and written to the security eventlog.
This will allow you to create a task scheduler that triggers on the generation of this event that calls a script that would run the process again. Simple right?
Well, you might have some trouble setting that task up especially when you want to pass details about the generating event to the script. This should help you get through that.
You can user Task scheduler for this purpose. There is a option of "restart on failure" which can be selected and whenever your process get failed it will restart again.
Reference :- https://social.technet.microsoft.com/Forums/windowsserver/en-US/4545361c-cc1f-4505-a0a1-c2dcc094109a/restarting-scheduled-task-that-has-failed?forum=winserverManagement

FileMaker scheduled script not running

I have a scheduled script that used to run just fine, but no longer is. The schedule is running my open script for the database (and completing it) but isn't even making it to the scheduled script that is supposed to get called.
I am testing by adding a "Freeze Window" step, which creates an error in the server log (incompatible with server). When I add it as the last line in the open script, it gets called and an error gets written to the log. When I add it as the first line in my scheduled script, it never gets called and there is no error in the log.
It looks like this:
Server opens database ->
Runs open script for database, to completion ->
Never runs scheduled script after open script
Any ideas or thoughts? Anyone seen anything like this before?
This is FileMaker Server 15 running on Windows Server.
I am starting to think this might be a file reference issue. Not sure if server is able to open up external databases and that might be causing issue?
FMS Scheduled scripts and PSoS can only work with FM files hosted on the same machine.
I am testing by adding a "Freeze Window" step, which creates an error in the server log (incompatible with server). When I add it as the last line in the open script, it gets called and an error gets written to the log. When I add it as the first line in my scheduled script, it never gets called and there is no error in the log.
IIRC, FMS will abort the script at the first incompatible step UNLESS Allow User Abort = OFF.
Note also that a Halt step in a subscript will stop the main script too.

running a script on startup and have it restart if crashed in debian

I have program that I need to run at startup in the background, so far I have it in rc.local like so:
sudo ./simple_program &
However this does not take into consideration if the program crashes. I need it so that whenever the program crashes, it is restarted again.
I think the approach is to write a bash script and run that instead in rc.local, where the bash script calls the simple_program and reruns it if needed. However, I'm not quite sure exactly what to do here. Could someone provide me a template?
Try with monit or daemontools, they are specifically designed to supervise other processes