gnu-parallel

run a bash for loop in parallel

心不动则不痛 提交于 2020-06-16 03:36:29
问题 I've got this script that does a credential lookup for each host, in an on-premise vault system, and then runs an ansible-playbook for it. #!/bin/bash for host in `cat ~/.ansible/hosts` do SECRET=`/opt/vault/bin/get-admin-credential --tag=$host` HOST=`echo $SECRET | cut -d ';' -f1` LOGIN=`echo $SECRET | cut -d ';' -f2` DOMAIN=`echo $SECRET | cut -d ';' -f3` PWD=`echo $SECRET | cut -d ';' -f4` if [ -z "$DOMAIN" ]; then ansible-playbook -i ~/.ansible/hosts ~/.ansible/windows.yml -e "ansible

zsh and parallel: How to use functions. It says command not found

早过忘川 提交于 2020-06-16 03:30:08
问题 I have a script file filename: test_sem_zsh.sh main() { echo "Happy day" } export -f main sem --id testing --fg main I am trying to run it using zsh $ zsh test_sem_zsh.sh test_sem_zsh.sh:export:4: invalid option(s) zsh:1: command not found: main It says two error's 1) main command not found and 2) export:4: invalid option(s) Where as when i try with bash it works $ sh test_sem_zsh.sh Happy day So how to get this script working with zsh also 回答1: Not certain what you are trying to do, but this

Executing shell commands in parallel but limiting jobs (Windows without Cygwin)

£可爱£侵袭症+ 提交于 2020-05-30 08:23:37
问题 Here is what I am trying to do. Suppose I have a program called myprogram.exe , which I have to execute 1000 times. Under Windows, I could usually do something as simple as: for /L %n in (1,1,1000) do start /myfolder/myprogram.exe However, suppose I only have 5 CPU threads I can devote to running the 1000 instances of myprogram.exe , such that I launch only 5, then when one of these finishes another one is launched, etc until the whole 1000 end. Under Linux and using GNU Parallel, I could

How do I get GNU parallel to work on git bash in Windows 7?

白昼怎懂夜的黑 提交于 2020-05-17 03:25:38
问题 I was able to install GNU Parallel globally in git-bash by following this answer. However, on running an example command as mentioned in the parallel-tutorial, parallel -k echo ::: A B C > abc-file I keep getting this error sh: -c: option requires an argument sh: -c: option requires an argument sh: -c: option requires an argument . . . What am I doing wrong here? 回答1: So the root cause is that CygWin (contrary to GNU/Linux) does not respect redirection of STDERR if the command line is too

Running a loop bash curl script with GNU Parallel

牧云@^-^@ 提交于 2020-04-16 03:15:13
问题 Just recently started programming in bash and came across GNU Parallel, which is exactly, what I need for my project. Have a basic loop script, which is meant to loop through the list of ip's and ping each, one time. The list with the ip's is constantly updated with the new ones, driven by the other script. For multithreading, I would like to use the GNU Parallel. My idea was to run 10 Parallel instances, each will capture one ip from the list, insert it into the curl command and removes it

calling shell function using parallel with list of quoted filenames as input

孤街浪徒 提交于 2020-03-03 07:46:06
问题 Using Bash. I have an exported shell function which I want to apply to many files. Normally I would use xargs, but the syntax like this (see here) is too ugly for use. ...... | xargs -n 1 -P 10 -I {} bash -c 'echo_var "$@"' _ {} In that discussion, parallel had an easier syntax: ..... | parallel -P 10 echo_var {} Now I have run into the following problem: the list of files to which I want to apply my function is a list of files on one line, each quoted and separated by spaces thus: "file 1"

How to make gnu-parallel split multiple input files

送分小仙女□ 提交于 2020-01-15 09:16:10
问题 I have a script which takes three arguments and is run like this: myscript.sh input1.fa input2.fa out.txt The script reads one line each from input1.fa and input2.fa , does some comparison, and writes the result to out.txt . The two inputs are required to have the same number of lines, and out.txt will also have the same number of lines after the script finishes. Is it possible to parallelize this using GNU parallel ? I do not care that the output has a different order from the inputs, but I

How to write multicore sorting using GNU Parallel

筅森魡賤 提交于 2020-01-15 09:06:57
问题 GNU Parallel GNU parallel is a shell tool for executing jobs in parallel using one or more computers For example, if I want to write a multicore version of wc I could do: cat XXX | parallel --block 10M --pipe wc -l | awk 'BEGIN{count=0;}{count = count+ $1;} END{print count;}' My question is how to do sorting using parallel? I know what I should do is pipe the result of parallel to a "merge sorted files" command(just like the final merge in merge sort), but I don't know how to do that. 回答1:

Fork processes indefinetly using gnu-parallel which catch individual exit errors and respawn

谁都会走 提交于 2020-01-15 06:50:33
问题 I guess the title gives you this thought. Another duplicate question Well, let me explain this in detail. Okay, here we go. I am using gearman to handle stack of tasks. I have a gearman client which send this task to workers. To run these task concurrently, there must be more workers to handle a task at a time. Presently, I create workers as per number of cpus. In my case, its 4 . So, 4 processes . ./worker & ./worker & ./worker & ./worker . I have same file running concurrently. But, I don't

bash loop with GNU less that refreshes every 2 minutes

妖精的绣舞 提交于 2020-01-15 03:58:07
问题 I have a linux machine with a data folder and a script that produces a report xlsx spreadsheet file on the ever changing content of the folder where it is being run. I use a xlsx2tsv script to convert it to tsv text which takes less than one second. The script takes about 1 minute to produce the spreadsheet file and I want to have a terminal screen showing the results of the table in a GNU less buffer, where I can move around with the cursors, and search for content with /search , etc. of the