Answer the question
In order to leave comments, you need to log in
How to run a script under windows without being attached to it?
Script 1 runs on the scheduler and checks if script 2 is running and runs it if not. Script 2 runs in an infinite loop (daemon). It is necessary that script 1 starts script 2 and ends (closes itself), and does not wait for script 2 to close.
In CentOS, this was solved like this: "nohup SCRIPT_2 1>/dev/null 2>/dev/null &"
Is there a similar solution under windows? "start /min SCRIPT_2 >NUL" doesn't help. Script 1 window remains running and waits for script 2 to close
Answer the question
In order to leave comments, you need to log in
The solution under Windows is to run the script through the start command - it definitely works, I personally checked it 200 times and you don't need to convince me otherwise.
If it doesn’t work for you, then you need to figure out why, errors or what? If it's just waiting for closing, show the code of your script1, the part where start +- is a few lines.
And yes, I hope your script1/2 in real life have other names and are not called start.bat for example.
Can you suggest going the other way? Use Mutex.
You only need one (main) script in this case, which starts like this (php):
<?php
$lock = @fopen('bot.lock', 'w');
if (false === $lock || false === @flock($lock, LOCK_EX | LOCK_NB)) {
return;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question