I am uisng script command to execute a binary. As soon as the execution starts , it ends the next moment. Please see the logs below
08:46:01 + script -c '/home/jenkins/workspace/slack-bot-test/s3-storage-e2e-test -kubeconfig /clusters/s3-e2e-test/kube-config-s3-e2e-test.yml -host https://xxx:23530' log.txt
08:46:01 Script started, file is log.txt
08:46:01 Script done, file is log.txt
I have a task scheduled to run daily that executes a .bat file and I have checked the options for ending the task after an hour and forcing it to stop if it does not end when requested to, but it runs indefinitely until I manually kill it. Any ideas? (I do not want to use pskill in my script). Script below:
sqlcmd -S MyServer -U username -P password _Q "BACKUP DATABASE x to y"
net use z: "\\server1\project"
cd C:\trial1
copy * "Z:\backups"
net use z: /delete
exit
Thanks to Hans Passant for the answer! See below:
Taking away 'net use' and just directly copying to the server cleared up some error that the task scheduler was getting stuck on.
Below is the snip of a Batch script scheduled for daily execution via Window's task scheduler. However, the time interval option isn't available in the scheduler.
echo open <hostname> >tmp.txt
echo <username> >>tmp.txt
echo <password> >>tmp.txt
:: Some Work
echo quit>>tmp.txt
ftp -i -s:tmp.txt
Need some guidance on making the script run between 5AM-10PM, every 30mins, using batch commands.
I have this batch script:
C:\{Directory}\PsExec.exe -u {UserName} -p {Password} \\{IP_Address} /accepteula "C:\batchfiles\{BatchScript}.bat"
And the {BatchScript}.bat script is:
C:\{Directory}\infacmd.bat wfs startWorkflow -DomainName {Domain_Name} -ServiceName {Service_Name} -UserName {Username} -Password {Password} -Application {Application} -Workflow {Workflow} -wait
This script kicks off an Informatica process to build a data warehouse (not sure if that's important, but thought I would mention it). When I run the first batch script, it kicks off the second batch script. However, it seems like command prompt waits for Informatica to be finished before it exits. My issue is that I have other processes that need to run, and this process takes 5 hours currently. Is there a command I can add on to my second (or first) script that will exit command prompt immediately after it kicks off? I don't believe this will impact the data warehouse build since I don't need Windows to monitor the process.
start "windowtitle" C:\...whatever...\infacmd.bat w....
should do what you want...
i have 3 commands to run in Windows terminal, but all of them should start in parallel roughly at the same time. I created .bat file, put my 3 commands in there and had run that bat file. But the commands are being executed in serial fashion(second command executes only after first one is finished). Is there a special way to do this in Windows?
What if i have to run the same command/exe i parallel, but with different arguments? I mean, lets suppose i have two commands, iperf.exe -s -u -i 1 10.10.100.1 and iperf.exe -s -u -i 1 10.10.100.2; Will these execute in parallel if i enter below lines in .bat file and run it?
start iperf.exe -s -u -i 1 10.10.100.1
start iperf.exe -s -u -i 1 10.10.100.2
And, even if they run in parallel, will there be any interruptions(even the slightest) while executing parallel processes like if one thread is dependent on another or will they execute strictly parallel like each command is an independent process? Because i need the programs to run at the same time and they should behave like separate and independent processes without any dependency or interruptions. Will START provide me with such kind of functionality?
In batch, use the start command, followed by the command you want to launch. All arg:
start iperf.exe -s -u -i 1 10.10.100.1
start iperf.exe -s -u -i 1 10.10.100.2
In PowerShell, use Start-Process (you can also call it "start", that's a built-in alias for Start-Process:
Start-Process iperf.exe -ArgumentList '-s -u -i 1 10.10.100.1'
Start-Process iperf.exe -ArgumentList '-s -u -i 1 10.10.100.2'
[Note: My answer appears to repeat information from the question because the question was edited to include information from my answer. The original question didn't mention the start command, it just asked how to start processes in parallel using batch or PowerShell.]
To answer the revised question: Both cmd's start and PowerShell's Start-Process spwan a child process, not a thread in the original process. In Windows, child processes are entirely independent from each other and from the parent. I've used both of these many, many times to launch applications that run separately, and can assure you that their operation is no more interdependent than if you had launched them in any other way.
The equivalent of start in PowerShell is Start-Process as has been pointed out but getting the parameters to the exe is a bit tricky e.g.:
Start-Process iperf -arg -s,-u,-i,1,10.10.100.1
Start-Process iperf -arg -s,-u,-i,1,10.10.100.2
I assume the exe runs until you press Ctrl+C or press enter? Otherwise the window opens, runs and then exits.
I think you just can't, neither in batch, nor in OS.
To minimize OS process loading overhead, you may try via Windows API to load all process suspended (CreateProcess, CREATE_SUSPENDED) and then, in a fast cycle start all threads (ResumeThread).
But I can't see any way to do that with command line, you have to go through programming.
Sorry to post it as a Reply, but not enough reputation to comment.
Insteady of:
Start-Process iperf -arg -s,-u,-i,1,10.10.100.1
Start-Process iperf -arg -s,-u,-i,1,10.10.100.2
You can do:
$params='-s -u -i 1 '
$ips=#('10.10.100.1','10.10.100.2')#and other more ips
$ips | foreach-Object{ Start-Process iperf -ArgumentList "$($params)$($_)"}
Then you can get the IP's from a list file, escalate and more.
I was looking for something like this when I've find your question.