Power Shell background tasks

Start background tasks
For example, perform ping 114.114.114.114 in the background

Start-Job -ScriptBlock {ping 114.114.114.114}

From the return, you can see the basic information of the job

Id     Name            PSJobTypeName   State         HasMoreData     Location             Command                  
--     ----            -------------   -----         -----------     --------             -------                  
1      Job1            BackgroundJob   Running       True            localhost            ping 114.114.114.114 

In addition to Start-Job, there are commands that can perform tasks remotely, Invoke-Command

View background tasks

Get-Job

The result is as follows

Id     Name            PSJobTypeName   State         HasMoreData     Location             Command                  
--     ----            -------------   -----         -----------     --------             -------                             
1      Job1            BackgroundJob   Completed     True            localhost            ping 114.114.114.114
3      Job3            BackgroundJob   Running       True            localhost            Sleep -Seconds 10 

Stop background tasks

Stop-Job -Id 1

Remove background tasks

Remove-Job -Id 1

other

Chia script

new-item -path $env:userprofile\.chia\mainnet\ -name plotter -type directory
Start-Job -ScriptBlock {
cd "$ENV:LOCALAPPDATA\chia-blockchain\app-1.1.6\resources\app.asar.unpacked\daemon\"
.\chia plots create -n 99 -r 4 -b 3390 -u 64 -f b2d36be2a6c0xxxxxxxxxxxxxxx8fef70dc11244 -p a4ab1376bcded8xxxxxxxxxxxxxxxab11cdeb24bf494 -t "D:\" -d "Z:\01" | tee -filepath $env:userprofile\.chia\mainnet\plotter\plots-5-21-2021-D1.txt
}

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

%d 博主赞过: