1. 작업 배경
background로 실행하는 batch 스크립트 같은 것을 workflow component로 실행 할
때 component가 종료되지 않고 계속 실행되는 경우가 있다.
2. Step by Step Guid
1) Linux
– ssh로 실행
=> 제약없음. 기존에 background 실행방식 그대로 유지하면 됨.
– agent로 실행
=> agent로 실행시 output이 더이상 나오지 않을 때까지 대기하기에
background로 실행하는 batch의 output도 redirecting 시켜줘야 한다.
예:
#!/bin/bash
nohup longRunBatch.sh &
anotherLongRunBatch.sh > /tmp/output_file.txt 2>&1 &
echo “succcess!!”
exit 0
2) Windows
– Winrm으로 실행
아래와 같이 관제서버에서 사용자 정의스크립트를 만들어준다.
스크립트 type: powershell
스크립트 내용:
Invoke-WmiMethod -path win32_process -name create -argumentlist
“c:\longrunScript.bat”
– MCCS Agent로 실행
=> background로 실행하는 script를 감싸줘는 powershell script를 노드에
만들어줘야 한다.
예:아래와 같은 내용으로 c:\wraper.ps1를 만들어준다.
Invoke-WmiMethod -path win32_process -name create -argumentlist
“c:\longrunScript.bat”
=> 아래와 같이 관제서버에서 만들어놓은 powershell를 실행하도록 사용자
정의스크립트를 만들어준다.
스크립트 type: batch
스크립트 내용:
@echo off
cmd /c (echo success) | powershell.exe -noprofile -executionpolicy bypass –
file “C:\Program Files\MCCS\script\start\wraper.ps1”
exit 0