I would like to run some commands after my target executable has been run.
I know that I can add "Before launch" tasks; is there such a thing as an "After launch" task?
Related
Calling the below bash script from Jenkins pipeline but I don't see the script execution on Jenkins console, can someone please advise how to display execution on jenkins console, bash script execution which is running on cygwin(on windows agent)
bat'call D:\cygwin64\bin\mintty.exe /usr/bin/bash -lic \"/home/test.sh\" '
One possible way to accomplish this is to go to "Manage Jenkins", "Configure System", and change the "Shell executable" parameter to your cygwin bash address. As your example shows, something like D:\cygwin64\bin\bash.exe. Then, on the job configuration, you can select on "Build", "Execute Shell". You can paste your test.sh script content in there. Like this:
With this configuration, Jenkins will run whatever you pasted in the "Execute shell" screen using the bash.exe address you provided in the configuration. I believe this is the most seamless way to execute shell scripts on Jenkins running on windows. The output looks almost Linux native:
I have a very simple bat file which does a MysqlDump.
When I manually execute the bat file, it works. When I click "execute" in my scheduled taks, it works. But the scheduled task itself, doesn't run when it should run (timer expires).
I've setup a scheduled task to run every 5 minutes. In the scheduled taks manager I can see "next time to execute" "16:55". But when it is 16:55 the text updates to "next time to execute" "17:00". But in the "previous time executed" nothing changes. It still shows the time I manually have executed the task.
So, the weird thing is, when I click "execute" for the task, it runs. But when the time expires and it should run by itself, nothing happend.
I've enabled the history for the task. But even there nothing happens.
Can you help?
I'm trying to schedule a script to run on windows. The triggering part works fine. The important part of my script looks like:
start C:\staging-script -arg1 arg -arg2 arg & ECHO "Did staging"
start C:\prod-script -arg1 arg -arg2 arg & ECHO "Did prod"
When I run it from cmd.exe, two more cmd windows are opened, both execute the script, and then the windows don't close. When I try to use Windows scheduler for this, it fails because the "resource is still in use"
Additionally, the ECHOs happen in the original window (which is where they should happen) but happen right away, not when the start task completes.
start creates an independent process. Once the process is started, the message is produced and the next line executed.
If you want the two started processes to execute in parallel and you're only bothered by those processes' windows' not closing, insert
exit
in the scripts started
If you want to execute the processes serially, that is complete process1 before producing the message and starting process2, then CALL the batches, don't start them.
try adding exit to the end of each script the windows execute.
I have scheduled a task in windows server 2008R2 ..I want to run a VBScript so when I setup the task I call the cscript at C:\Windows\System32\cscript.exe and in the arguments section I am passing //nologo //B d:\main\programs\copy.vbs /targets:contents but it is not executing my script ..If I call my script directly in the start program section it works fine but it's not working if I call CSrcipt and pass in arguments the status changes to queued but nothing happens after that..Can someone tell me what I am doing wrong here.
Also another question I have is that can we run 2 programs one after another in one task like when one script is finished I would like to start another script .
Thanks
Put this line at the top of your script and try again:
CreateObject("WScript.Shell").LogEvent 4, "Script running"
Unless you get an Information event with source WSH and event-ID 4, your script isn't running at all. Check the eventlog and the task's History tab for clues as to why that is. Also check the permissions of the script. Is the runas account of the task able to access/run the file? You can check that by starting a CMD instance as that user
runas /user:DOM\USER cmd
and then trying to run the script in that CMD instance.
Also double-check the task settings. As which user is it configured to run? With the user logged on or not logged on? Is "Run with highest privileges" enabled (in case UAC is enabled on your server)?
If the script does produce the abovementioned event that means it's running in principle, but something is going wrong in the process. You need to debug your script.
I am using bash on Ubuntu. I would like to have a shell script open a program and continue on to the next line of the shell script, even though the program has not terminated.
Adding an & to a command places it in background.
example:
/path/to/foo
/path/to/bar # not executed untill foo is done
/path/to/foo & # in background
/path/to/bar & # executes as soon as foo is started
Read more about job-control here and here
Use something like this (my-long-running-process &) . This will launch your script as a separate process in the background.
You must run the process in the background, but you must enable job-control first. Otherwise, you cannot kill or bring the process to foreground if desired.
To enable job-control, execute:
set -m
To run some task in the background, execute:
task &
To manipulate the background task, use the jobspec syntax (%[n]). For example, to kill the last launched process, execute:
kill %
Note that enabling job-control is required only if you're actually running a script (as stated in the question). If running interactively, job-control is already enabled by default.
The manpage for bash has much more information in the JOB CONTROL section.
http://ubuntuforums.org/showthread.php?t=1657602
It looks like all you have to do is add a & at the end of the line.