How to use Start-Job?
Hello folks,
I am trying to setup a simple Start-Job command. This basic command works for me and copies the file correctly.
Start-Job -Scriptblock {Copy-Item -Path \\192.168.32.25\share\butterfly.jpg -Destination c:\test\ -Recurse -Verbose}
However, it does not work when I try using variable like this.
$source = "\\192.168.32.25\share\butterfly.jpg"
$target = "c:\test\"
Start-Job -Scriptblock {Copy-Item -Path $source -Destination $target -Recurse -Verbose}
Anyone have suggestions for getting this to work with variables?
Thanks,
romatlo
Hi,
Here's some information:
http://powershell.org/wp/forums/topic/passing-parameter-to-start-job/
https://social.technet.microsoft.com/Forums/scriptcenter/en-US/ff644fca-1b25-4c8a-9a8a-ce90eb024389/in-powershell-how-do-i-pass-startjob-arguments-to-a-script-using-param-style-arguments?forum=ITCG
Basically, look at using -ArgumentList:
http://ss64.com/ps/start-job.html
Don't retire TechNet! -
(Don't give up yet - 13,225+ strong and growing)
Similar Messages
-
Using Start-Job to launch multiple SSH sessions and esxtop?
Hello folks,
I am trying to start an esxtop session on multiple esx servers at the same time.
I started trying using Start-Job thinking it would help do it asynchronously.
The script I have below works on one host so far, but need suggestions to repeat it for multiple hosts, thinking by looping through changing the $i each time?
Checking if anyone would have comment?
$i = 1
$seconds = 5
$iterations = 2
$esxtopfile = "esxtop$i_$((Get-Date).ToString('MMddyyy-hhmm')).csv"
$ComputerName = "z420esxi$i.domain.net"
# Start an esxtop session using SSH.net and start an esxtop command - module already loaded.
$sb = {New-SshSession -ComputerName $($args[0]) -KeyFile C:\esxi-key-openssh.key -Username root
Invoke-SshCommand -ComputerName $($args[0]) -command "esxtop -d $($args[1]) -a -b -n $($args[2]) > /tmp/$($args[3])"
Start-Job -ScriptBlock $sb -ArgumentList $ComputerName,$seconds,$iterations,$esxtopfile | Wait-Job | Receive-Job
You're starting for a job, waiting for that job to complete and then finally receiving that job
before allowing anything else to happen with your script.
In other words, if you had some code after the Start-Job line, it would not be executed until the job had completed and you had received the job, which partially negates the benefits of using a job to begin with (specially bearing in mind you don't have
a form).
The way to achieve what you're after is to start all jobs at the same time, one per ESX host, and then finally to wait for all jobs and collect all jobs at the end.
Here's a quick example that starts 5 jobs and wait for all of them to complete before receiving the results.
$jobs = @()
$jobs += 1..5 | ForEach-Object {Start-Job -ScriptBlock {Sleep $args[0]; "I just slept for $($args[0]) seconds"} -ArgumentList $_}
[void] (Wait-Job $jobs)
Receive-Job $jobs
Notice that each of the subsequent jobs will take longer and longer to run, with the first being the fastest and the last the slowest. Still, I'm waiting for *all* jobs to complete before performing the Receive-Jobs on all of them at the same time.
You're starting for a job, waiting for that job to complete and then finally receiving that job
before allowing anything else to happen with your script.
In other words, if you had some code after the Start-Job line, it would not be executed until the job had completed and you had received the job, which partially negates the benefits of using a job to begin with (specially bearing in mind you don't have
a form).
The way to achieve what you're after is to start all jobs at the same time, one per ESX host, and then finally to wait for all jobs and collect all jobs at the end.
Here's a quick example that starts 5 jobs and wait for all of them to complete before receiving the results.
$jobs = @()
$jobs += 1..5 | ForEach-Object {Start-Job -ScriptBlock {Sleep $args[0]; "I just slept for $($args[0]) seconds"} -ArgumentList $_}
[void] (Wait-Job $jobs)
Receive-Job $jobs
Notice that each of the subsequent jobs will take longer and longer to run, with the first being the fastest and the last the slowest. Still, I'm waiting for *all* jobs to complete before performing the Receive-Jobs on all of them at the same time.
Hi, All
I have a application need periodically check an instrument status and I put it in the "Timeout Event" in main vi. I also need call some subVis for configuration etc. Somehow when I called those subvi, the Timeout event in my main vi was not running. Then I use " Start Asynchronous Call" function to call the subVis. Turns out it works fine with some subvis without return value, but not as expected with "return value-needed" subvis.
I attached a simple test, my main vi call two dlg subvis: AboutDlg.vi and SettingsDlg.vi. In the timeout event, I just use a counter for simulation. When you run it, you can see the counter keep counting when the AboutDlg.vi was called, but stopped when SettingsDlg.vi was called.
As I remembered, someone suggested to use Queue to pass return value, but I don't know how to implement it here.
Anyone has any suggestions about it?
Thank you very much.
CQ
Solved!
Go to Solution.
Attachments:
AsyCallTest.llb 108 KB
Try playing with this - I have modified your code to poke a Q in there.
You will want to change the clusters to more useful datatypes (maybe enum and variant so you can unbundle variants depending on enum input), you will want to type def the clusters to make it easier to maintain and you will NEED to handle the sitaution where the called VI is left open on program close - i couldn't be bothered as this was not your immediate issue)
Hope this give you some Ideas - totalyy untested but should work.
James
Attachments:
AsyCallTest.llb 114 KB
PowerShell using start job to run multiple code blocks at the same time
I will be working with many 1000’s of names in a list preforming multiple function on each name for test labs.
I notice when it is running the functions on each name I am using almost no CPU or memory. That led me to research can I run multiple threads at once in a PowerShell program. That lead me to articles suggesting start-job would do just want I am looking
for.
As a test I put this together. It is a simple action as an exercise to see if this is indeed the best approach. However it appears to me as if it is still only running the actions on one name at a time.
Is there a way to run multiple blocks of code at once?
Thanks
Start-Job {
$csv1 = (Import-Csv "C:\Copy AD to test Lab\data\Usergroups1.csv").username
foreach ($name1 in $csv1) { Write-Output "Job1 $name1"}
Start-Job {
$csv2 = (Import-Csv "C:\Copy AD to test Lab\data\Usergroups2.csv").username
foreach ($name2 in $csv2) { Write-Output " Job2 $name2"}
Get-Job | Receive-Job
Lishron
You say your testing shows that you are using very little cpu or memory in processing each name, which suggests that processing a single name is a relatively trivial task.
You need to understand that using a background job is going to spin up another instance of powershell, and if you're going to do that per name what used to require a relatively insignificant amount of memory is going to take around 60 MB.
Background jobs are not really well suited for multi-threading short-running, trivial tasks. The overhead of setting up and tearing down the job session can be more than the task itself.
Background jobs are good for long-running tasks. For multi-threading short, trivial tasks runspaces or a workflow would probably be a better choice.
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
How to use Start Task Group for Workflow Interface
Hi all,
anyone who can tell me how to use the Interface IFWFTSKGRP (Start Task Group for Workflow Interface)?
As far as I understood the documentation it can be used to restrict the selection of workflows that can be started in the Generic Object Services. But the question is how to implement it.
Best regards,
Carsten
Edited by: Carsten Drewes on Jun 10, 2009 10:30 AM
Hi, Carsten,
(probably it's a bit too late to post an answer after 3 years , but I'll post it in case someone else needs it)
You should implement GetTaskGroup method.
The code should return id of the task group (otype TG, mantained in PFTC) that holds the list of workflow definitions.
Here is a sample implementation. It's taken from FORMABSENC business object. It belongs to SAP demo workflow "Notification of Absence". I suppose it should be present in most systems and you can see it in action.
begin_method gettaskgroup changing container.
DATA: taskgroup LIKE rhobjects-object.
*- set task group
taskgroup = 'TG70000023'.
*- set result
swc_set_element container result taskgroup.
end_method.
Receive location of job after using Start-job command
Hey all so I have a script that installs software on remote machines. I've recently started using Psexec to start installing as the System account, however now I am not able to keep track of the location that Psexec is running on. The old method I could
call the variable I stored the job in "$job.location" and receive the location but now when I do this I get localhost.
Here's the code:
###Software Install methods
if($checkboxUserInstall.Checked){
#Uses users creds to install software
foreach($item in $computersForInstall){
$installArrayJobs += Invoke-Command -ComputerName $item -ScriptBlock {cmd /c "C:\Package\$($args[0])"} -ArgumentList $softwareInstallerName -AsJob -Credential $cred
}else{
#New PsExec Install method
$installString = { PsExec.exe "\\$($args[0])" -s -accepteula "C:\Package\$($args[1])" }
Write-Host "Starting $($software[$index][0]) Installs.."
foreach($item in $computersForInstall){
$installArrayJobs += Start-Job $installString -ArgumentList $item, $softwareInstallerName
I think I understand why, the top invoke command is actually invoking that command on the remote machine so it is able to keep track of the location. The bottom is using Psexec to invoke the command and cannot keep track of it.
So long story short is there anyway I can keep track of the location while using the bottom Psexec method and the Start-Job command?
Thanks.
You can leverage the -Name property of Start-Job to keep track of the server the job was for.
###Software Install methods
if($checkboxUserInstall.Checked){
#Uses users creds to install software
foreach($item in $computersForInstall){
$installArrayJobs += Invoke-Command -ComputerName $item -ScriptBlock {cmd /c "C:\Package\$($args[0])"} -ArgumentList $softwareInstallerName -AsJob -Credential $cred
}else{
#New PsExec Install method
$installString = { PsExec.exe "\\$($args[0])" -s -accepteula "C:\Package\$($args[1])" }
Write-Host "Starting $($software[$index][0]) Installs.."
foreach($item in $computersForInstall){
$installArrayJobs += Start-Job $installString -Name $item -ArgumentList $item, $softwareInstallerName
Now, instead of the default Job1, Job2, etc. job names, each job will have a name that matches the server the job was for.
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
How i use start with and rollup both in one query
hi master
sir i use rollup function for subtotal but rollup not give tree
for tree i want to use start with and connect by function
but that query give error
sir how i use both rollup and start with connect by in one query
for tree wise subtotal
please give me idea
thanking you
hi master
thank for your reply
sir i get accid and title from master table and balance from detial table then system give me error
sir i send me all table and data with query and error
Sir this is my master table
SQL> desc chartofacc;
Name Null? Type
PARENT NUMBER
CHILD NUMBER
ACCID NOT NULL VARCHAR2(15)
TITLE VARCHAR2(99)
CAMPID VARCHAR2(2)
ACTIVE NUMBER
FSTATUS NUMBER
Data
Parent child accid
1 K1
1 11 K11
11 1101 K1101
11 1102 K1102
11 1103 K1103
11 1104 K1104
11 1105 K1105
11 1106 K1106
11 1107 K1107
11 1108 K1108
11 1109 K1109
11 1110 K1110
11 1111 K1111
11 1112 K1112
11 1113 K1113
11 1114 K1114
1 12 K12
12 1201 K1201
12 1202 K1202
12 1203 K1203
1 13 K13
13 1301 K1301
1301 130101 K130101
1301 130102 K130102
1301 130103 K130103
1301 130104 K130104
1301 130105 K130105
1301 130106 K130106
1301 130107 K130107
1301 130108 K130108
1301 130109 K130109
1301 130110 K130110
1301 130111 K130111
1301 130112 K130112
1301 130113 K130113
1301 130114 K130114
1301 130115 K130115
13 1302 K1302
1302 130201 K130201
1302 130202 K130202
1302 130203 K130203
1302 130204 K130204
1302 130205 K130205
13 1303 K1303
1303 130301 K130301
1303 130302 K130302
1303 130303 K130303
13 1304 K1304
1304 130401 K130401
1304 130402 K130402
1304 130403 K130403
1304 130404 K130404
1304 130405 K130405
1304 130406 K130406
1304 130407 K130407
1304 130408 K130408
13 1305 K1305
1305 130501 K130501
1305 130502 K130502
13 1306 K1306
1306 130601 K130601
13 1307 K1307
1307 130701 K130701
1307 130702 K130702
1307 130703 K130703
1307 130704 K130704
13 1308 K1308
1308 130801 K130801
1308 130802 K130802
1308 130803 K130803
1308 130804 K130804
1308 130805 K130805
1308 130806 K130806
1308 130807 K130807
1308 130808 K130808
1308 130809 K130809
1308 130810 K130810
1308 130811 K130811
1308 130812 K130812
1308 130813 K130813
13 1309 K1309
13 1310 K1310
13 1311 K1311
1311 131101 K131101
2 K2
2 21 K21
21 2101 K2101
2101 210101 K210101
2101 210102 K210102
2101 210103 K210103
2101 210104 K210104
21 2102 K2102
2102 210201 K210201
2102 210202 K210202
2102 210203 K210203
2102 210204 K210204
21 2103 K2103
2103 210301 K210301
2103 210302 K210302
2103 210303 K210303
2103 210304 K210304
21 2104 K2104
2104 210401 K210401
2104 210402 K210402
2104 210403 K210403
2104 210404 K210404
2 22 K22
22 2201 K2201
2201 220101 K220101
2201 220102 K220102
2201 220103 K220103
2201 220104 K220104
2201 220105 K220105
22 2202 K2202
2202 220201 K220201
2202 220202 K220202
2202 220203 K220203
2202 220204 K220204
22 2203 K2203
2203 220301 K220301
2203 220302 K220302
2203 220303 K220303
2203 220304 K220304
22 2204 K2204
2204 220401 K220401
2204 220402 K220402
2204 220403 K220403
22 2205 K2205
2205 220501 K220501
2205 220502 K220502
220502 22050201 K22050201
220502 22050202 K22050202
220502 22050203 K22050203
220502 22050204 K22050204
22 2206 K2206
2206 220601 K220601
2206 220602 K220602
2206 220603 K220603
2206 220604 K220604
2 23 K23
23 2301 K2301
2301 230101 K230101
2301 230102 K230102
2301 230103 K230103
2301 230104 K230104
2301 230105 K230105
2301 230106 K230106
2301 230107 K230107
2301 230108 K230108
23 2302 K2302
2302 230201 K230201
2302 230202 K230202
2302 230203 K230203
2302 230204 K230204
23 2303 K2303
2303 230301 K230301
2303 230302 K230302
23 2304 K2304
2304 230401 K230401
2304 230402 K230402
2304 230403 K230403
23 2305 K2305
2305 230501 K230501
23 2306 K2306
2306 230601 K230601
2306 230602 K230602
2306 230603 K230603
2306 230604 K230604
23 2307 K2307
23 2308 K2308
2308 230801 K230801
2308 230802 K230802
2308 230803 K230803
23 2309 K2309
2309 230901 K230901
2309 230902 K230902
2309 230903 K230903
2309 230904 K230904
23 2310 K2310
2310 231001 K231001
2310 231002 K231002
2310 231003 K231003
23 2311 K2311
2311 231101 K231101
2311 231102 K231102
2311 231103 K231103
23 2312 K2312
2312 231201 K231201
2312 231202 K231202
2312 231203 K231203
2312 231204 K231204
23 2313 K2313
2313 231301 K231301
2313 231302 K231302
2313 231303 K231303
2313 231304 K231304
2313 231305 K231305
2313 231306 K231306
2313 231307 K231307
2313 231308 K231308
2313 231309 K231309
2313 231310 K231310
2313 231311 K231311
2313 231312 K231312
2313 231313 K231313
2313 231314 K231314
2313 231315 K231315
23 2314 K2314
2314 231401 K231401
2314 231402 K231402
2314 231403 K231403
2314 231404 K231404
2314 231405 K231405
2314 231406 K231406
2314 231407 K231407
23 2315 K2315
23 2316 K2316
2316 231601 K231601
2316 231602 K231602
23 2317 K2317
23 2318 K2318
23 2319 K2319
2319 231901 K231901
2319 231902 K231902
2319 231903 K231903
2319 231904 K231904
2319 231905 K231905
2319 231906 K231906
23 2320 K2320
2320 232001 K232001
3 K3
3 31 K31
31 3101 K3101
31 3102 K3102
31 3103 K3103
31 3104 K3104
31 3105 K3105
3 32 K32
32 3201 K3201
32 3202 K3202
32 3203 K3203
32 3204 K3204
32 3205 K3205
32 3206 K3206
32 3207 K3207
4 K4
4 41 K41
41 4101 K4101
4101 410101 K410101
4101 410102 K410102
4101 410103 K410103
4101 410104 K410104
4101 410105 K410105
4101 410106 K410106
4101 410107 K410107
4101 410108 K410108
4101 410109 K410109
4101 410110 K410110
4101 410111 K410111
4101 410112 K410112
4101 410113 K410113
4101 410114 K410114
4101 410115 K410115
4101 410116 K410116
4101 410117 K410117
4101 410118 K410118
4101 410119 K410119
4101 410120 K410120
4101 410121 K410121
4101 410122 K410122
4101 410123 K410123
4101 410124 K410124
4101 410125 K410125
4101 410126 K410126
4101 410127 K410127
4101 410128 K410128
4101 410129 K410129
4101 410130 K410130
4101 410131 K410131
4101 410132 K410132
41 4102 K4102
41 4103 K4103
41 4104 K4104
4104 410401 K410401
4104 410402 K410402
4104 410403 K410403
4104 410404 K410404
41 4105 K4105
41 4106 K4106
41 4107 K4107
41 4108 K4108
4108 410801 K410801
4108 410802 K410802
4108 410803 K410803
41 4109 K4109
4109 410901 K410901
4109 410902 K410902
4109 410903 K410903
41 4110 K4110
41 4111 K4111
4111 411101 K411101
4111 411102 K411102
4111 411103 K411103
41 4112 K4112
4112 411201 K411201
41 4113 K4113
4113 411301 K411301
41 4114 K4114
4114 411401 K411401
4114 411402 K411402
5 K5
5 51 K51
51 5101 K5101
51 5102 K5102
51 5103 K5103
51 5104 K5104
51 5105 K5105
51 5106 K5106
51 5107 K5107
51 5108 K5108
51 5109 K5109
51 5110 K5110
51 5111 K5111
51 5112 K5112
51 5113 K5113
51 5114 K5114
6 K6
6 61 K61
7 K7
7 71 K71
7 72 K72
7 73 K73
7 74 K74
7 75 K75
7 76 K76
This is my detil table
SQL> desc accbal;
Name Null? Type
ACCID VARCHAR2(15)
YEARID NUMBER
CRBAL NUMBER
DRBAL NUMBER
ENTDATE DATE
BALID NUMBER
Data in detail
K1101 46291132
K1102 13182173
K1103 23784045
K1107 10001795
K1108 9083529
K1110 4224350
K1112 6696832
K1113 7963381
K1114 742766
K1201 1486082
K130104 1977616
K130106 736266
K130107 396673
K130108 42751
K130109 298362
K130110 187696
K130111 537
K130112 942
K130113 987
K130114 1272
K130115 40000
K130205 259941
K130303 177716
K130406 809719
K130408 1786091
K130701 301000
K130702 151200
K130703 7570
K130704 34400
K1308
K130801 5400
K130802 45000
K130803 10856
K130807 24300
K130808 16500
K130810 104500
K130811 60000
K130812 181000
K130813 1750000
K1309 1225565
K1310 2176259
K1311
K131101 788780
K410101 24926
K410102 9545
K410103 28500
K410104 8192
K410105 847
K410106 37100
K410107 2332
K410108 9844
K410109 7843
K410110 9313
K410111 1425
K410112 6089
K410113 15497
K410114 5790
K410115 4251
K410116 22293
K410117 855
K410118 6497
K410119 14996
K410120 124214
K410121 6713
K410122 1567
K410123 75821
K410124 5085
K410125 7125
K410126 4342
K410127 21485
K410128 641111
K410129 589
K410130 50
K410131 163900
K410132 3849
K4105 3946489
K4107 100000
K410801 972011
K410802 1707806
K410803 116450
K4110 13113874
K411101 98335
K411102 32454
K411103 53569
K411201 25327406
K411301 7143103
K411401 4500000
K411402 12754
K5102 2120031
K5103 13543810
K5107 4596103
K5108 5604493
K5110 2008401
K5112 2182778
K5113 4748537
K5114 556914
K61 43297680
Sir I use this query
select lpad(' ',2*(level-1)) || to_char(child),title,sum(drbal),sum(crbal),
from chartofacc, accbal
where chartofacc.accid=accbal.accid(+)
start with parent is null
connect by prior child = parent
group by rollup(substr(mas.accid,2,1),substr(mas.accid,3,1),substr(mas.accid,4,2),substr(mas.accid,6,2) ,chartofacc.accid,title,fstatus);
sir this query not give me result and give me error this
SQL> /
from chartofacc, accbal
ERROR at line 2:
ORA-00936: missing expression
Please give me idea how I get tree type subtotal tribalance
Thanking you
Aamir
How to use "start" and "duration" with HLS stream
Hi all,
is it possible to use "start" and "stop" with HLS stream like rtmp stream?
If yes, how?
thanks in advance.
Hi,
This is completely player side fucntionality you are asking for. However, I guess default player that comes on safari (iPad), quicktime has the player timeline with stop and start option. But if not, you can create your custom player using exposed api of AVPlayer. Check-out AVPlayer api's.
FMS, by nature of protocol will respect the request to get the data(in case of client-play-start) and will not automatically push the data to the client if not asked for by the client (as in case of client-play-stop).
Thanks
I have this in my technical design interace:
We need to know which processing program we have to call:
SELECT SINGLE PROCPROG
INTO l_procprog
FROM ZGL_MPF_CONFIG
WHERE interfacename = INTERFACENAME.
Open a job with this processing program ( the processing program should be a function module which creates an Idoc).use functions JOB_OPEN and JOB_CLOSE.
How i have to use this sentences?
Thx
1.u can use like this
2.
report abc.
BREAK-POINT.
DATA : JN(32) TYPE C.
JN = 'JOB001'.
BREAK-POINT.
DATA : J(8) TYPE C.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
DELANFREP = ' '
JOBGROUP = ' '
jobname = JN
SDLSTRTDT = NO_DATE
SDLSTRTTM = NO_TIME
JOBCLASS =
IMPORTING
JOBCOUNT = J
CHANGING
RET =
EXCEPTIONS
CANT_CREATE_JOB = 1
INVALID_JOB_DATA = 2
JOBNAME_MISSING = 3
OTHERS = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
DATA : P TYPE PRI_PARAMS.
P-PDEST = 'PRINTER'.
P-PDEST = 'LOCL'.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING NO_DIALOG = 'X'
MODE = 'CURRENT'
NEW_LIST_ID = $PRNEW
IMPORTING OUT_PARAMETERS = P.
CALL FUNCTION 'JOB_SUBMIT'
EXPORTING
ARCPARAMS =
authcknam = 'MAMIT'
COMMANDNAME = ' '
OPERATINGSYSTEM = ' '
EXTPGM_NAME = ' '
EXTPGM_PARAM = ' '
EXTPGM_SET_TRACE_ON = ' '
EXTPGM_STDERR_IN_JOBLOG = 'X'
EXTPGM_STDOUT_IN_JOBLOG = 'X'
EXTPGM_SYSTEM = ' '
EXTPGM_RFCDEST = ' '
EXTPGM_WAIT_FOR_TERMINATION = 'X'
jobcount = J
jobname = JN
LANGUAGE = SY-LANGU
PRIPARAMS = P
REPORT = 'HINCF160'
VARIANT = 'A'
IMPORTING
STEP_NUMBER =
EXCEPTIONS
BAD_PRIPARAMS = 1
BAD_XPGFLAGS = 2
INVALID_JOBDATA = 3
JOBNAME_MISSING = 4
JOB_NOTEX = 5
JOB_SUBMIT_FAILED = 6
LOCK_FAILED = 7
PROGRAM_MISSING = 8
PROG_ABAP_AND_EXTPG_SET = 9
OTHERS = 10
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
AT_OPMODE = ' '
AT_OPMODE_PERIODIC = ' '
CALENDAR_ID = ' '
EVENT_ID = ' '
EVENT_PARAM = ' '
EVENT_PERIODIC = ' '
jobcount = J
jobname = JN
LASTSTRTDT = NO_DATE
LASTSTRTTM = NO_TIME
PRDDAYS = 0
PRDHOURS = 0
PRDMINS = 0
PRDMONTHS = 0
PRDWEEKS = 0
PREDJOB_CHECKSTAT = ' '
PRED_JOBCOUNT = ' '
PRED_JOBNAME = ' '
SDLSTRTDT = NO_DATE
SDLSTRTTM = NO_TIME
STARTDATE_RESTRICTION = BTC_PROCESS_ALWAYS
STRTIMMED = 'X'
TARGETSYSTEM = ' '
START_ON_WORKDAY_NOT_BEFORE = SY-DATUM
START_ON_WORKDAY_NR = 0
WORKDAY_COUNT_DIRECTION = 0
RECIPIENT_OBJ =
TARGETSERVER = ' '
DONT_RELEASE = ' '
TARGETGROUP = ' '
DIRECT_START =
IMPORTING
JOB_WAS_RELEASED =
CHANGING
RET =
EXCEPTIONS
CANT_START_IMMEDIATE = 1
INVALID_STARTDATE = 2
JOBNAME_MISSING = 3
JOB_CLOSE_FAILED = 4
JOB_NOSTEPS = 5
JOB_NOTEX = 6
LOCK_FAILED = 7
INVALID_TARGET = 8
OTHERS = 9
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
BREAK-POINT.
regards,
Ravi
How to use Start Routine for this requirement
Hello,
I am having data in 2 ods and should load that data into cube, but there isn't any common object in both the ods's. I need to analyze based on these ods objects. so I thought of pulling some objects into 1ods which are used for analysis and added some objects to ods and cube. Now I have to write a start routine in update rules to fetch the data from the info objects which are present in another ods. Can any one help me in this?
Rajesh.
Hi Surya,
Extract all info from table BKPF
select * into it_bkpf
from bkpf
where gjahr = p_fisyr.
Select record based on internal table it_BKPF
The reason why FOR ALL ENTRIES syntax is used because of its cluster table.
select * into it_bseg
from bseg
for all entries in it_bkpf
where bukrs = it_bkpf-bukrs
and belnr = it_bkpf-belnr.
Delete duplicate record based on Company Code and GL No.
delete adjacent duplicates from it_bseg
comparing bukrs belnr.
How to use start and reference trigger on HI-Scope digitizer
HI,
I would like to ask about the start and reference trigger with PCI-5124.
I found an sample VI on the following link, however it doesn't work as I expected.
http://zone.ni.com/devzone/cda/epd/p/id/2998
The VI "start_and_reference_trigger.vi" can detect both start and reference trigger in my system and they start data acquisition.
It starts data acquisition when both start and reference triggers are input.
However what I would like to do is:
1. Sampling rate at 200MHz with record length 1500 with one channel.
2. Receive the start trigger (i.e. 50Hz)
3. Receive the reference trigger (i.e. 50kHz)
4. For every reference trigger, I would like to acquire the data, i.e. acquiring 1500 data for each 100 reference trigger (not with the combination with the start trigger)
Start trigger: _|^|_________________________________________
Ref trigger:______|__|__|__|__|__|__|__|__|__|__|__|__|__|__|____
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
trigger timings that I would like to acquire
With the sample VI "start_and...", I found that it acquires when both start and reference trigger comes and the data acquisition is only after the one reference trigger.
I hope my explanation is understandable and I can have a solution soon.
解決済!
解決策の投稿を見る。
Hi Tom 1225,
Thanks for posting on Discussion Forum. Based on your statement, I guess, what you want PCI-5124 to do is what general bench-top type oscilloscopes do. To realize that functionality, at the end of each sampling of a record length, PCI-5124 has to rearm its trigger for its next sampling. The amount of "rearm time" is listed in "trigger" section on 5124 manual, said that the rearm time is 10[us] when TDC is ON and 2[us] when TDC is OFF. So, we have to keep in mind that, if one waveform of measured signal is shorter than 2[us] (TDC OFF), more than one waveform may fail to kick the trigger, because 5124 still rearming its trigger.
I made two samples and attached them on this post.
In "Sample SW Timing Trigger.vi", trigger rearm occurs at software timing, when the time NI-Scope Start function is called. In "Sample HW Timing Trigger.vi", trigger rearm occurs at hardware timing. As seen on the block diagram, for a hardware timing trigger rearm, the number in "number of records" of horizontal setting function should be equal to the times of the trigger-based measurements. If you have any question on my sample VIs, feel free to ask. If my post resolves your problem, please click on the green "解決策に決定" icon on my post.
Osamu Fujioka
Applications Enginner
National Instruments Japan
添付:
Sample SW Timing Trigger Rearm.vi 28 KB
Sample HW Timing Trigger Rearm.vi 31 KB
PowerShell - Start-Job - Synchronised Array list
Hi all,
I am trying to write a script using start-job against a list of machines. The script is to query a target machine event log using get-winevent cmdlet. I supply the whole code that queries the eventlog in a scriptblock. In order to capture the output (one
psobject for each of the scriptblock jobs) I am trying to use a synchronised arraylist. I do not know the full details of how to use the synchronised arraylist but I have put together the below script (by referring to some of the online articles). But the
script does not work as intended. The individual scriptblocks do not seem to be referring to the global arraylist variable while appending the results.
Would any of you be able to shed any light on it?
Please note, the script without the PowerShell Jobs works fine(that is linear execution which is really time-consuming). Also, even with using psJobs, the script works when I try to dump the result of each job into a csv from within the job itself. But I
want to avoid this situation because due to the asynchronous execution there might be contention for the csv by more than one jobs at the same time. Hence I want to use the synchronised array list.
$InputCSV = "$(Split-Path $SCRIPT:MyInvocation.MyCommand.Path -parent)\backupexec.csv"
$OutputCSV = "$(Split-Path $SCRIPT:MyInvocation.MyCommand.Path -parent)\Reports\BackupExec_Output_$(Get-Date -format "ddMMyyyy")_$((Get-Date).DayOfWeek).csv"
$OutputArray = [System.Collections.ArrayList]::Synchronized((New-Object System.Collections.ArrayList))
$counter=1
$jobs=@{};
$jobcounter=0;
Import-CSV $InputCSV | ForEach {
$Comp_Name=$_.ServerName;
$Counter+=1;
$Scriptblock={
Try {
$IsthereAnyResult= @()
$IsthereAnyResult= Get-WinEvent -ComputerName $Using:Comp_Name -ErrorAction SilentlyContinue -FilterHashTable @{LogName='application';ProviderName='Backup Exec';ID=57755; StartTime=(Get-Date).AddDays(-1)}
$props = @{
"Server Name" = ($event.MachineName -split '\.')[0];
"Event ID" = $event.ID;
"Time Logged" = $event.TimeCreated;
"Backup Result" = Switch ($event.ID) { '57755' {"Success - Skipped"}
'34113' {"Failed"}
'34112' {"Success"} };
"Message" = $event.Properties[0].value -replace '\n' -replace '\r';
$OutputArray += New-Object PSObject -Property $props
} #end try get-winevent
Catch { } #end Catch
} #end scriptblock
$jobs[$jobcounter]= Start-job -name $("Job_$jobcounter") -ScriptBlock $Scriptblock
$jobcounter+=1;
While((Get-Job -State 'Running').Count -ge 10) {
Start-Sleep -Milliseconds 10
} # end main foreach
Get-Job | Wait-Job
$OutputArray | Select-Object "Server Name","Event ID","Time Logged","Backup Result","Message" | Export-CSV -force -Path $OutputCSV -NoTypeInformation -Append
How about this?
I use wmi win32_ntlogevent which i prefer .. Timeservice is just for example ...
Change the scriptblock to your needs and report the result :]
Param ([int]$BatchSize=2)
#list of servers
[array]$source = (get-adcomputer -filter {name -like "server*"}) |select -expandproperty dnshostname
$blok = {
get-wmiobject Win32_NTLogEvent -Filter "(Logfile='System') and (SourceName = 'Microsoft-Windows-Time-Service')" |select -first 10 |select __server,@{n="EventCode";e={switch($_.EventCode){37{"37 - Receiving"}35{"35 - Synchronizing"}129{"129 - NTP Fail"}default{"Other EventCode"}}}},@{n="Date";e={$_.ConvertToDateTime($_.TimeGenerated)}},message
$elapsedTime = [system.diagnostics.stopwatch]::StartNew()
$result = @()
$itemCount = 0
## checking running jobs
if (get-job|? {$_.name -like "Script*"}){
write-host "ERROR: There are pending background jobs in this session:" -back red -fore white
get-job |? {$_.name -like "Script*"} | out-host
write-host "REQUIRED ACTION: Remove the jobs and restart this script" -back black -fore yellow
$yn = read-host "Automatically remove jobs now?"
if ($yn -eq "y"){
get-job|? {$_.name -like "Script*"}|% {remove-job $_}
write-host "jobs have been removed; please restart the script" -back black -fore green
exit
$i = 0
$itemCount = $source.count
Write-Host "Script will run against $itemcount servers!"
## Script start time mark
write-host "Script started at $(get-date -uFormat "%Y/%m/%d %H:%M:%S")".padright(60) -back darkgreen -fore white
write-host " (contains $itemCount unique entries)" -back black -fore green
$activeJobCount = 0
$totalJobCount = 0
write-host "Submitting background jobs..." -back black -fore yellow
for ($i=0; $i -lt $itemCount;$i += $batchSize){
$activeJobCount += 1; $totalJobCount += 1; $HostList = @()
$HostList += $source |select -skip $i -first $batchsize
$j = invoke-command -computername $Hostlist -scriptblock $blok -asjob
$j.name = "Script`:$totalJobCount`:$($i+1)`:$($getHostList.count)"
write-host "+" -back black -fore cyan -nonewline
write-host "`n$totaljobCount jobs submitted, checking for completed jobs..." -back black -fore yellow
while (get-job |? {$_.name -like "Script*"}){
foreach ($j in get-job | ? {$_.name -like "Script*"}){
$temp = @()
if ($j.state -eq "completed"){
$temp = @()
$temp += receive-job $j
$result += $temp
remove-job $j
$ActiveJobCount -= 1
write-host "-" -back black -fore cyan -nonewline
elseif ($j.state -eq "failed"){
$temp = $j.name.split(":")
if ($temp[1] -eq "R"){
$temp = @()
$temp += receive-job $j
$result += $temp
remove-job $j
$ActiveJobCount -= 1
write-host "-" -back black -fore cyan -nonewline
else{
write-host "`nFailure detected in job: $($j.name)" -back black -fore red
$temp = @()
$temp += receive-job $j
$result += $temp
remove-job $j
$ActiveJobCount -= 1
if ($result.count -lt $itemCount){
sleep 3
write-host " "
write-host "Script finished at $(get-date -uFormat "%Y/%m/%d %H:%M:%S")".padright(60) -back darkgreen -fore white
write-host (" Elapsed Time : {0}" -f $($ElapsedTime.Elapsed.ToString())) -back black -fore green
$result |select __server,eventcode,Date,message |ft -auto
write-host " Script completed all requested operations at $(get-date -uFormat "%Y/%m/%d %H:%M:%S")".padright(60) -back darkgreen -fore white
write-host (" Elapsed Time : {0}" -f $($ElapsedTime.Elapsed.ToString())) -back black -fore green
How to use quartz jobscheduling framework
how to use quartz job scheduling framework to send mails to a recipint when he places an order.
give idea abt how it is going to detect the placing of order.is there any listener to detect that
Edited by: sivaprasadrao on Jun 30, 2008 3:15 AM
Hi,
How does he places an order ?. It may be some block of your code. Include your mail function in that block.
Regards,
Ram.
How to send an updated list using batch job
Hi All,
The program displays data on the screen, if the data looks ok, then there is an option to update.
When I run update, the program submits a batch job and the basic list gets updated, but my batch job is still sending the data on the screen. how can i send the updated list using batch job.
Ex: output of the program
1 2
there is an update button on the screen, when i press update button, my program submits in batch job, the above list becomes
1 2
3 4
but when i check the spool, it shows the o/p as 1 2 ..it is not sending the updated list.
Please suggest me how to send the updated data
Thanks,
Kumar
Hi Krishna,
I have added a button on the alv list. when i press update button, my program updates the list, then submits the batch job. I am attaching the sample test program i am trying with, please suggest me how can i get the updated list.
*& Report ZTESTSSSSS
REPORT ZTESTSSSSS.
DATA: gt_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat type slis_t_fieldcat_alv,
gt_sort TYPE slis_t_sortinfo_alv,
g_repid LIKE sy-repid,
gt_layout TYPE slis_layout_alv.
start-of-selection.
lt_return-type = 'S'.
lt_return-message = 'test message'.
append lt_return.
CLEAR gt_fieldcat.
gt_fieldcat-fieldname = 'TYPE'.
gt_fieldcat-outputlen = '3'.
gt_fieldcat-tabname = 'LT_RETURN'.
gt_fieldcat-seltext_l = 'Type'.
gt_fieldcat-seltext_m = 'Type'.
gt_fieldcat-seltext_s = 'Type'.
APPEND gt_fieldcat TO lt_fieldcat.
CLEAR gt_fieldcat.
gt_fieldcat-fieldname = 'MESSAGE'.
gt_fieldcat-outputlen = '15'.
gt_fieldcat-tabname = 'LT_RETURN'.
gt_fieldcat-seltext_l = 'Message'.
gt_fieldcat-seltext_m = 'Message'.
gt_fieldcat-seltext_s = 'Message'.
APPEND gt_fieldcat TO lt_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = lt_fieldcat
TABLES
T_OUTTAB = lt_return
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
*& Form set_pf_status
text
-->RT_EXTAB text
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'STANDARD'.
ENDFORM. "Set_pf_status
*& Form user_command
text
-->R_UCOMM text
-->RS_SELFIELD text
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA: li_count TYPE I.
IF r_ucomm EQ 'UPD'.
Adding another message
lt_return-type = 'S'.
lt_return-message = 'Another test message'.
APPEND lt_return.
rs_selfield-refresh = 'X'.
rs_selfield-col_stable = 'X'.
rs_selfield-row_stable = 'X'.
l_upd = 'X'.
LOOP AT lt_return.
WRITE: / lt_return-type, lt_return-message.
ENDLOOP.
IF sy-batch IS INITIAL.
l_upd = 'X'.
Open the Job
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = w_name
IMPORTING
jobcount = w_number
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc = 0.
SUBMIT ('ZTESTSSSSS') VIA JOB w_name NUMBER w_number
AND RETURN
WITH p_recnnr = p_recnnr.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = w_number
jobname = w_name
strtimmed = 'X'
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
OTHERS = 8.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. "User_command
Thanks,
Kumar
How to call a stored procedure on time basis with out using sql job and GOTO
Hi,
I wanted to call a stored proc, on time basis ,
please tel me how it can be done with out using sql job , goto .
1) That is, is there any timer aviable in sqlserver.
q2) And which one is better GOTO or sql job.
yours sincerley
Raj, Check if my explanation helps you:
Your job runs every 10 seconds.
Lets say first time you are scheduling and running your job at 12:00:00 PM
Now your proc will start executing.
Say it got finished at 12:00:07.
Now the next schedule time is 12:00:10 PM.
The moment this time hits, the job will get invoked and start executing the proc.
Lets say this time it finished at 12:00:22 PM (It took 2 extra seconds)
This time the scheduled time is already gone (12:00:20 PM), thus it'll now run at the next schedule that is 12:00:30 PM.
Thus if anytime your job takes more than 10 seconds to run, it'll just miss those particular schedules overlapping with execution time. Otherwise you are good to go.
PS: A job is the best way to handle this, in your problem statement you don't need a job but that would be wrong. You have another way to do that, if you keep running your procedure all the time and the moment your timestamp hits a multiple of 10
seconds you can run your logic and then returning to the timer. But this is extremely wrong for a system. Even if your requirement is extremely transactional and complex, I would not suggest this. If the job is taking more than 10seconds (which it might if
your logics inside are complex), you should optimize your code and table architecture.
Chaos isn’t a pit. Chaos is a ladder. Many who try to climb it fail and never get to try again. The fall breaks them. And some are given a chance to climb, but they refuse. They cling to the realm, or the gods, or love. Illusions. Only the ladder is real.
The climb is all there is.
Maybe you are looking for
-
App store wont allow me to download apps. what do i do?
Everytime i try to download an app, or update it, it takes me to the Payment Transaction screen where the payment methods are listed and asks me to change them. However I had a prepaid card on there which is now out money and when i enter the securit
-
Can't open attachments anymore
Hi all, I have a weird problem where I can no longer open any email attachments that are files. JPGs and the like that are attached come through in the body of the email just fine. But Word docs, PDFs, Excel docs, etc cannot be opened. Nor can I even
-
Cannot import stills with Ken Burns effect
I apply Ken to the clip, tell it to update or apply it to a clip and drag it into the timeline. I get the status window showing it is importing, then I get an alert sound and the clip with the effect is not there. Tied removing he plist but that made
-
Hi all, How should i create an interactive report with two radio buttons?. When i clicks the radio button it should retrive the corresponding row and display that in SQL report(should be editable-with in same page)- Should i use tabular form instead
-
SAP Portal Integration with Documentum
Hello All - I am Documentum person and new to SAP Portal and Integration. I need to know can we Integration the SAP Portal with Documentum 6.7. If yes, What all components required from SAP product and my requriement is below. a. Create Forms / GUI t