date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,386,277,472,000
Given a file like: a b c How do I get an output like: a 0cc175b9c0f1b6a831c399e269772661 b 92eb5ffee6ae2fec3ad71c777531578f c 4a8a08f09d37b73795649038408b5f33 in an efficient way? (Input is 80 GB)
This could just be a oneliner in perl: head 80gb | perl -MDigest::MD5=md5_hex -nlE'say"$_\t".md5_hex($_)' a 0cc175b9c0f1b6a831c399e269772661 b 92eb5ffee6ae2fec3ad71c777531578f c 4a8a08f09d37b73795649038408b5f33 d 8277e0910d750195b448797616e091ad e e1671797c52e15f763380b45e841ec32 f ...
Compute md5sum for each line in a file
1,386,277,472,000
Suppose we want to dispatch jobs to a collection of servers using GNU parallel. What would happen if one of the servers die(power failure, thermal shutdown...) while busy executing a job? Will GNU parallel just dispatch the same job to another server or will that job be lost forever?
It will be lost forever unless you use --retries in which case it will be retried on another server. Also have a look at --filter-hosts to remove hosts that are down.
GNU parallel ssh jobs: What happens to an incomplete job if the server dies?
1,386,277,472,000
ls *.txt | parallel 'echo Starting on file {}; mkdir {.}; cd {.}; longCMD3 ../{} > /dev/null; echo Finished file {}' This one liner partially works, except longCMD3 takes about 3 minutes, but the first and second echo commands are printed almost at the same time. I tried putting in wait before the final echo, but th...
For each file, the commands echo Starting on file foo.txt, mkdir foo, cd foo, longCMD3 ../foo.txt > /dev/null and echo Finished file foo.txt run sequentially, i.e. each command starts after the previous one has finished. The commands for different files are interspersed. By default, the parallel command runs as many j...
Why does my parallel command print “Starting” and ”Finished“ at the same time?
1,386,277,472,000
I need to run grep on a couple of million files. Therefore I tried to speed it up, following the two approaches mentioned here: xargs -P -n and GNU parallel. I tried this on a subset of my files (9026 in number), and this was the result: With xargs -P 8 -n 1000, very fast: $ time find tex -maxdepth 1 -name "*.json" |...
Try parallel -X. As written in the comments the overhead of starting a new shell and opening files for buffering for each argument is probably the cause. Be aware that GNU Parallel will never be as fast as xargs because of that. Expect an overhead of 10 ms per job. With -X this overhead is less significant as you proc...
GNU parallel excessively slow
1,386,277,472,000
I have a bash script that takes as input three arrays with equal length: METHODS, INFILES and OUTFILES. This script will let METHODS[i] solves problem INFILES[i] and saves the result to OUTFILES[i], for all indices i (0 <= i <= length-1). Each element in METHODSis a string of the form: $HOME/program/solver -a <method...
Summary of the comments: The machine is fast but doesn't have enough memory to run everything in parallel. In addition the problem needs to read a lot of data and the disk bandwidth is not enough, so the cpus are idle most of the time waiting for data. Rearranging the tasks helps. Not yet investigated compressing the ...
BASH: parallel run
1,386,277,472,000
I have a 0-byte-delimited file of records. Record 1, Line 1 Record 1, Line 2 [zero byte] Record 2, Line 1 Record 2, Line 2 I'd like to run the "process.sh" command once for each record, with the record as standard input: bash process-one-record-stdin.sh <record-contents Can I do this with xargs, parallel, or some ot...
If you have GNU Parallel you can do this: parallel --rrs --recend '\0' -N1 --pipe bash process-one-record-stdin.sh <record-contents All new computers have multiple cores, but most programs are serial in nature and will therefore not use the multiple cores. However, many tasks are extremely parallelizeable: Run the s...
xargs, records, and standard input
1,386,277,472,000
GNU Parallel is outputting hidden directories as follows using the --results parameter. What command do I use on Ubuntu to change the all to directories so that they are no longer hidden. The directories are called: '.\_ValidateAll.sh GL 170'/ '.\_ValidateAll.sh GL 190'/ '.\_ValidateAll.sh GL 220'/ '.\_ValidateAll.sh ...
If the only issue is that the directories are hidden, you can just remove the . from the beginning of their name to make them unhidden. For example, using perl-rename (called rename on Ubuntu): rename 's/^\.//' '.\_Validate'* Or, with just shell tools: for dir in '.\_Validate'*; do echo mv "$dir" "${dir//.}"; done B...
Rename all hidden directories created by GNU parallel
1,386,277,472,000
I am copying the files from machineB and machineC into machineA as I am running my below shell script on machineA. If the files is not there in machineB then it should be there in machineC for sure so I will try copying the files from machineB first, if it is not there in machineB then I will try copying the same file...
If I understand this code correctly I believe this is your issue: do_Copy() { el=$1 PRIMSEC=$2 scp david@$FILERS_LOCATION_1:$dir3/new_weekly_2014_"$el"_200003_5.data \ $PRIMSEC/. || \ scp david@$FILERS_LOCATION_2:$dir3/new_weekly_2014_"$el"_200003_5.data \ $PRIMSEC/. } export -f do_Copy parallel --...
MaxStartups and MaxSessions configurations parameter for ssh connections?
1,386,277,472,000
Possible Duplicate: How to run a command when a directory's contents are updated? I'm trying to write a simple etl process that would look for files in a directory each minute, and if so, load them onto a remote system (via a script) and then delete them. Things that complicate this: the loading may take more than...
It sounds as if you simply should write a small processing script and use GNU Parallel for parallel processing: http://www.gnu.org/software/parallel/man.html#example__gnu_parallel_as_dir_processor So something like this: inotifywait -q -m -r -e CLOSE_WRITE --format %w%f my_dir | parallel 'mv {} /tmp/processing/{/};m...
process files in a directory as they appear [duplicate]
1,386,277,472,000
parallel from moreutils is a great tool for, among other things, distributing m independent tasks evenly over n CPUs. Does anybody know of a tool that accomplishes the same thing for multiple machines? Such a tool of course wouldn't have to know about the concept of multiple machines or networking or anyhting like tha...
GNU Parallel does that and more (using ssh). It can even deal with mixed speed of machines, as it simply has a queue of jobs, that are started on the list of machines (e.g. one per CPU core). When one jobs finishes another one is started. So it does not divide the jobs into clusters before starting, but does it dynami...
Multi-machine tool in the spirit of moreutils' `parallel`?
1,386,277,472,000
I've been trying to process the output of find with parallel, which in turn invoked a shell (some textual substitutions were needed). I observed some strange behaviour, which I cannot really explain to myself. In each directory there are a bunch of files, call them file1.xtc, file2.xtc. Some of them have names such as...
Your problem has nothing to do with bash. In fact, since you're telling parallel to run sh, you may not even be using bash. The issue is that parallel is not really a drop-in replacement for xargs, as its documentation indicates. Instead, it accumulates its arguments into a single string (with spaces between them) and...
Variable declaration in parallel sh -c …
1,386,277,472,000
If I run a command with nice, then I can see its process having the expected niceness value: In one terminal: nice sleep 17 and in another one: $ ps -aoni,comm | grep sleep 10 sleep But trying to do the same with GNU parallel (version 20161222, Debian 9.3), I fail: parallel --nice 10 sleep ::: 17 $ ps -aoni,comm |...
You have found a bug. Thanks. It was introduced in parallel-20160522, and until now did not have any automated testing to check that --nice was working locally. Next release will have both testing and --nice working. The workaround for local jobs is to run parallel with nice: nice -n 18 parallel bzip2 '<' ::: /dev/zer...
Why is parallel --nice not setting the niceness?
1,494,413,974,000
I'm trying to use GNU Parallel to run a comman mutliple times with a combination of constant and varying arguments. But for some reason the constant arguments are split on white-space even though I've quoted them when passing them to parallel. In this example, the constant argument 'a b' should be passed to debug-call...
parallel runs a shell (which exact one depending on the context in which it is called, generally, when called from a shell, it's that same shell) to parse the concatenation of the arguments. So: parallel debug-call 'a b' {} ::: 'a b' c is the same as parallel 'debug-call a b {}' ::: 'a b' c parallel will call: your-...
Prevent GNU parallel from splitting quoted arguments
1,494,413,974,000
I want to extract frames as images from video and I want each image to be named as InputFileName_number.bmp.  How can I do this? I tried the following command: ffmpeg -i clip.mp4 fr1/$filename%d.jpg -hide_banner but it is not working as I want.  I want to get, for example, clip_1.bmp, but what I get is 1.bmp. I am tr...
$filename is handled as a shell variable. What about ffmpeg -i clip.mp4 fr1/clip_%d.jpg -hide_banner or $mp4filename=clip ffmpeg -i ${mp4filename}.mp4 fr1/${mp4filename}_%d.jpg -hide_banner ? Update: For use with gnu parallel, you can use parallel's -i option: -i Normally the command is passed the argument at the...
How to include input file name in output file name in ffmpeg
1,494,413,974,000
I'm using the following script to copy multiple files into one folder: { echo $BASE1; echo $BASE2; echo $BASE3; } | parallel cp -a {} $DEST Is there any way to use only one echo $BASE with brace expansion? I mean something like this: { echo $BASE{1..3} } | parallel cp -a {} $DEST
You could use an array: BASES[0]=... BASES[1]=... BASES[2]=... # or BASES+=(...) # or BASES=(foo bar baz) echo "${BASES[@]}" | parallel cp -a {} $DEST To make it safer (spaces and newlines in the variable in particular), something like this should work more reliably: printf "%s\0" "${BASES[@]}" | parallel -0 cp -a {}...
Copy multiple files to one dir with parallel
1,494,413,974,000
GNU Parallel, without any command line options, allows you to easily parallelize a command whose last argument is determined by a line of STDIN: $ seq 3 | parallel echo 2 1 3 Note that parallel does not wait for EOF on STDIN before it begins executing jobs — running yes | parallel echo will begin printing infinitely ...
A bug in GNU Parallel does, that it only starts processing after having read one job for each jobslot. After that it reads one job at a time. In older versions the output will also be delayed by the number of jobslots. Newer versions only delay output by a single job. So if you sent one job per second to parallel -j10...
Make GNU Parallel not delay before executing arguments from STDIN
1,494,413,974,000
I want to convert a bunch of Webp images to individual PDFs. I'm able to do it with this command: parallel convert '{} {.}.pdf' ::: *.webp or I can use this FFMPEG command: find ./ -name "*.webp" -exec dwebp {} -o {}.pdf \; However during the process of conversion the Webp files are decoded and the resultant PDFs have...
Why not just use Imagemagick and Ghostscript? convert img.webp img.pdf gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dPDFSETTINGS=/ebook -sOutputFile=img-small.pdf img.pdf In my test with your sample file I got a pdf result of about 3.2 MB. EDIT You could follow these instructions on Ubuntu to make sure that imagemagick wa...
Convert Webp to PDF
1,494,413,974,000
The GNU parallel grepping n lines for m regular expressions example states the following: If the CPU is the limiting factor parallelization should be done on the regexps: cat regexp.txt | parallel --pipe -L1000 --round-robin grep -f - bigfile This will start one grep per CPU and read bigfile one time per CPU, bu...
It is due to GNU Parallel --pipe being slow. cat bigfile | parallel --pipe -L1000 --round-robin grep -f regexp.txt - maxes out at around 100 MB/s. In the man page example you will also find: parallel --pipepart --block 100M -a bigfile grep -f regexp.txt which does close to the same, but maxes out at 20 GB/s on a ...
GNU Parallel - grepping n lines for m regular expressions
1,494,413,974,000
I have a directory ~/root/ |-- bar |-- eggs |-- foo |-- hello.txt |-- script.sh `-- spam 4 directories, 2 files Issuing find . -type d while in ~/root/ yields . ./spam ./eggs ./bar ./foo However, issuing find . -type d | parallel "echo {}" ::: * yields bar eggs foo hello.txt script.sh spam Why are the nondirectori...
According to the manual, the ::: * syntax uses the shell's expansion of * as an argument list instead of anything from stdin. So as written, your command ignores the result of find and passes all files in the current directory as arguments. If you leave off the ::: *, it should work as intended.
Why is find piping in non directories when the “-type d” test is used?
1,494,413,974,000
I have files like this on a Linux system: 10S1_S5_L002_chrm.fasta SRR3184711_chrm.fasta SRR3987378_chrm.fasta SRR4029368_chrm.fasta SRR5204465_chrm.fasta SRR5997546_chrm.fasta 13_S7_L003_chrm.fasta SRR3184712_chrm.fasta SRR3987379_chrm.fasta SRR4029369_chrm.fasta SRR5204520_chrm.fasta SRR599754...
Your basename command only removes the fixed .fasta extension - as far as I know it cannot remove a variable pattern. However GNU parallel provides a Perl expression replacement string facility that is much more powerful than basename - ex. given $ ls *_chrm.part*.fasta ERR358546_chrm.part-2.fasta ERR358546_chrm.part...
How can I use basename with parallel?
1,494,413,974,000
I can't undestand well how the parallel command works. I need to run this simple command: (100 times) curl https://jsonplaceholder.typicode.com/todos/1 curl https://jsonplaceholder.typicode.com/todos/2 curl https://jsonplaceholder.typicode.com/todos/3 ... curl https://jsonplaceholder.typicode.com/todos/100 end redi...
Well, this is a somewhat over-engineered Bash-solution, but it works and hopefully clarifies the use of the parallel command: function xx(){ curl "https://jsonplaceholder.typicode.com/todos/$1" > "$1.txt";} parallel xx -- {1..100} The first line creates a new "command" or function called xx which - when executed - ca...
Run parallel command and redirect the output to files with specific name
1,494,413,974,000
I've found answers close to this but fail to understand how to use them in my case (I'm rather new to Bash)... so, I'm trying to process a folder containing a large image sequence (100k+ files) with Imagemagick and would like to use GNU Parallel to speed things up. This is the code I use (processing 100 frames at a t...
Order Your sample program did not seem to care about the order of the *.png for the allframes array that you were constructing, but your comments led me to believe that order would matter. I guess what I would want to do is to have parallel splitting the load like handing the first 100 frames to core 1, frames 100-19...
GNU parallel with for loop?
1,494,413,974,000
Suppose I have a list of commands in file cmd_file. I run these commands via: cat cmd_file | parallel -k -I {} "{}" One of the commands fails. All of the commands use the exact same CLI tool with different inputs. Right now, I have to run across all of the commands one at a time to find the erroring command by subst...
You can instruct parallel to print each command executed either to standard output or to standard error. From the man page: -v Print the job to be run on stdout (standard output). Can be reversed with --silent. See also -t. -t Print the job to be run on stderr (standard error). So perhaps: for ...; do # as...
Can GNU Parallel be made to output the command line executed when run in linewise mode?
1,494,413,974,000
I am using the following grep script to output all the unmatched patterns: grep -oFf patterns.txt large_strings.txt | grep -vFf - patterns.txt > unmatched_patterns.txt patterns file contains the following 12-characters long substrings (some instances are shown below): 6b6c665d4f44 8b715a5d5f5f 26364d605243 717c8a919a...
A much more efficient answer that does not use grep: build_k_mers() { k="$1" slot="$2" perl -ne 'for $n (0..(length $_)-'"$k"') { $prefix = substr($_,$n,2); ...
Boosting the grep search using GNU parallel
1,494,413,974,000
1. Summary I don't understand, how I can combine parallel and sequential commands in Linux. 2. Expected behavior Pseudocode: pip install pipenv sequential pipenv install --dev parallel task npm install -g grunt-cli sequential npm install Windows batch working equivalent: start cmd /C "pip install pipenv & pipenv inst...
Simply with GNU parallel: parallel ::: 'pip install pipenv && pipenv install --dev' \ 'npm install -g grunt-cli && npm install'
Combine parallel and sequential commands
1,494,413,974,000
On my home machine, I use the script gitpull.sh to concurrently pull all the changes to the git repos under a given directory. #!/usr/bin/bash find $1 -name ".git" | sed -r 's|/[^/]+$||' | parallel git -C {} pull origin master My problem is that parallel is not installed on my work computer. Is it possible to alter ...
Instead of parallel you could use xargs with the -P flag. Something like: find $1 -name ".git" | sed -r 's|/[^/]+$||' | xargs -I {} -n 1 -P 0 git -C {} pull origin master
Can I concurrently pull my git repos without gnu parallel?
1,494,413,974,000
I'd like to just check the status of a bunch of Git repos with a quick command like parallel git -C {} status --short ::: ~/*/.git/... But the Git status doesn't include the repo name or path, so I'd need some way to print either the git command run by parallel or (ideally) just the input (the ~/[…]/.git/.. part of th...
Try: parallel --tagstring {//} git -C {//} status --short ::: ~/*/.git or: parallel --plus --tagstring {=s:$HOME.::';s:/.git::'=} git -C {//} status --short ::: ~/*/.git or: parallel -v git -C {//} status --short ::: ~/*/.git It is not exactly what you ask for, but may be an acceptable solution. A solution matching...
How to print GNU Parallel command & output together?
1,494,413,974,000
As GNU parallel's manual shows, you can use a zenity progress bar with parallel: seq 1000 | parallel -j30 --bar '(echo {};sleep 0.1)' \ 2> >(zenity --progress --auto-kill) | wc However, in that example, the cancel button doesn't work. I've read about similar issues with this button when used with more usual comma...
Zenity is desinged to read two lines, one for progress bar and one begining with "#" for progress text: for ((i=0;i<=100;i++));do echo "$i" # bar echo "#percent done $i" # text sleep .1 done | zenity --progress I guess that --bar option writes progress to stderr but doesn't close it or doesn...
Zenity Cancel button for GNU parallel progress bar
1,494,413,974,000
I want to extract all lines of $file1 that start with a string stored in $file2. $file1 is 4 GB large with about 20 million lines, $file2 has 2 million lines, is about 140 MB large and contains two columns separated with ,. The maximal line length of both files is well below 1000, they are sorted with LC_ALL=C and $fi...
It is covered in man parallel https://www.gnu.org/software/parallel/man.html#EXAMPLE:-Grepping-n-lines-for-m-regular-expressions EXAMPLE: Grepping n lines for m regular expressions. The simplest solution to grep a big file for a lot of regexps is: grep -f regexps.txt bigfile Or if the regexps are fixed strings: grep...
filtering a large file with a large filter
1,494,413,974,000
I have about two hundred sub-directories located within a directory of interest: $ ls backup 201302 201607 201608 201609 201610 201701 201702 201705 201801 201802 I want to create a 7z archive xyz.7z for each directory xyz: cd $HOME/backup/ 7z a "storage/nas/TBL/compressed_backups/$xyz.7z" "$xyz" -mmt=4 So in the en...
Use the following approach: ls backup | parallel -j5 7z a -mmt=4 "storage/nas/TBL/compressed_backups/{}.7z" {} {} - input line. This replacement string will be replaced by a full line read from the input source.
Create separate 7z archives for each directory in the current directory and additionally parallelize through GNU Parallel
1,494,413,974,000
I have a file with many lines, and on each line I have the arguments I want to pass to parallel with a tab separator. I run this script cat $hdd_file | grep $ssd | parallel -C '\t' clean_and_destroy And it works, $hdd_file is the filename, the grep collects the lines which hdds have a certain $ssd as a cache, and the...
GNU parallel solution: Sample input.txt (for demonstration): a b c d e f grep '^[ac]' input.txt will be used to emulate command(or pipeline) acting like input source file parallel -C '\t' echo :::: <(grep '^[ac]' input.txt) ::: $(seq 1 3) The output: a b 1 a b 2 a b 3 c d 1 c d 2 c d 3 :::: argfiles - tre...
gnu parallel pair argument with file input arguments
1,494,413,974,000
I have an input file, names.txt, with the 1 word per line: apple abble aplle With my bash script I am trying to achieve the following output: apple and apple apple and abble apple and aplle abble and apple abble and abble abble and aplle aplle and apple aplle and abble aplle and aplle Here is my...
GNU Parallel can generate all combinations of input sources. In your case you simply use names.txt twice: parallel -k echo {1} and {2} :::: names.txt names.txt Or (if you really have an array): readarray -t seqcol < names.txt parallel -kj 20 echo {1} and {2} ::: "${seqcol[@]}" ::: "${seqcol[@]}"
Iterating over array elements with gnu parallel
1,494,413,974,000
I found a script on GitHub which I've slightly modified to fit the needs of the program I'm trying to run in a queue. It is not working however and I'm not sure why. It never actually echos the jobs to the queue file. Here is a link to the GitHub page: https://gist.github.com/tubaterry/c6ef393a39cfbc82e13b8716c60f7824...
You don't need this complex script, parallel can do what want by itself. Just remove the .inp extension from your list of files using sed or any other tool of your choice, and feed the base name to parallel like this: sed 's/\.inp//' jobs.txt | parallel -j 16 "${PROGRAM} {}.inp > {}.log 2> {}.err" The {} notation is ...
A GNU Parallel Job Queue Script
1,494,413,974,000
I need to use parallel and set the rate limit per second, because I need to query an API that has a "5 per second" rate limit. Do I must combine -n5 and --timeout 1? Thank you
You are looking for --delay 0.2.
gnu parallel: how to set the limit per second
1,494,413,974,000
I want to run four processes in parallel, but not spawn any new jobs until all of these four have finished. EDIT: My command looks like this: find . -name "*.log" | parallel -j 4 './process.sh {}'
That very question has recently been put on the mailing list: https://lists.gnu.org/archive/html/parallel/2019-06/msg00003.html The short answer is: As GNU Parallel is now, it cannot do this. A (crappy) workaround is here: https://lists.gnu.org/archive/html/parallel/2019-06/msg00008.html in-line: #!/bin/bash parpar()...
Is there a way to tell GNU parallel to hold off spawning new jobs until all jobs in a batch has finished?
1,494,413,974,000
I have a list of java reserved words, first letter capitalised. $ tail -n5 ~/reservedjava.txt Break While True False Null I'm trying to look through all my java source code to find methods that look like getWhile(). cat ~/reservedjava.txt | parallel 'ag "get{}\(\)$"' This shows me nothing. Now, I know that I have a ...
cat ~/reservedjava.txt | parallel 'ag "get{}\(\)$"' This doesn't work because ag wants a path argument. Eg, search where. This works, recursively search starting at the current directory: cat ~/reservedjava.txt | parallel 'ag "get{}\(\)$" ./'
No output using parallel in tandem with ag or ack
1,494,413,974,000
Suppose I have a file like this: COLUMN 1 2 3 4 If I wanna run and process it with GNU parallel but skipping first line aka header, I tried this: parallel -a test.txt -k --pipepart --will-cite --skip-first-line cat However, --skip-first-line is not working as I expect: parallel -a test.txt -k --pipepart --will-cite ...
I found a solution using the replacement string {#} aka sequence number. The first header will always be in sequence 1, hence we can treat this specially when we parse it. For example with a script: #!/bin/bash _test() { if [[ "$1" == 1 ]]; then : else cat fi } export -f _test parallel -...
--skip-first-line in GNU parallel not working with --pipepart?
1,494,413,974,000
I am trying to run code across a network of external nodes. I have access to the 'main' node through ssh, and can execute a parallel script that divides the jobs over the cluster of 5 available nodes. I have a bash script that contains the parallel command, among other necessary components. The final command I am usi...
To keep the connection alive you can often use ServerAliveInterval. It can be set in .ssh/config.
ssh_askpass Permission denied, when using GNU parallel, even when using nohup
1,494,413,974,000
This is my case scenario: luis@Balanceador:~$ echo ${array[@]} a b luis@Balanceador:~$ echo ${array[1]} a luis@Balanceador:~$ echo ${array[2]} b luis@Balanceador:~$ parallel echo ${array[]} ::: 1 2 -bash: ${array[]}: bad substitution luis@Balanceador:~$ parallel echo ${array[{}]} ::: 1 2 -bash: {}: syntax error: opera...
While it looks easy, it is really very hard. Jobs started by GNU Parallel are not started inside the same shell as GNU Parallel is run from. So it looks like this: bash[1]---perl(running parallel)---bash[2] $array is defined in bash[1] but you want to use it in bash[2]. It is impossible to do completely (i.e. if you ...
GNU Parallel: How can I reference array elements?
1,494,413,974,000
I'm compiling a huge list of commands (all doing the same thing) I want executed, but as it takes a long time to compile that list, I would like execution to begin before I'm done (execution of each command typically takes longer than creating another, so there's no real risk of the list running dry). The normal way t...
From: https://www.gnu.org/software/parallel/man.html#example-gnu-parallel-as-queue-system-batch-manager true >jobqueue; tail -n+0 -f jobqueue | parallel --joblog my.log & echo my_command my_arg >> jobqueue my_job_generator >> jobqueue This will give you a record (my.log) of which jobs have completed. GNU Parallel ver...
Adding to while executing a list of commands
1,494,413,974,000
I have some files Joapira___BERLINA_DEL_HIERRO.mp4 Joapira___EL_BAILE_DEL_VIVO.mp4 Joapira___EL_CONDE_CABRA.mp4 Joapira___FLAIRE.mp4 Joapira___MAZULKA_DEL_HIERRO.mp4 Joapira___MEDA_A_MANOLITO_DIAZ_ARTESANO_TALLISTA.mp4 that I want to convert to some other formats with ffmpeg and GNU parallel. For example to convert ...
Solution is —as suggested by @OleTange in a comment— to update to a newer version of parallel, i.e. GNU parallel 20161122. EVerything works again. And it is better to protect the commands from shell interaction with single quotes, i.e.: parallel --bar 'ffmpeg -i {} -map_metadata 0 {/.}.flac' ::: * and parallel --bar ...
gnu parallel with ffmpeg does not process first file
1,494,413,974,000
This command works fine for dir with "regular" names as dir1 mydir my-dir, etc ls | parallel 'echo -n {}" "; ls {}|wc -l' give me the number of files for each dir but for dir with white spaces like "my dir" or my long dir name don't work and give error. How to quote/escape the white spaces?
Assuming that you only want to list the number of regular files in the sub-directories from where you execute your cmd, here is a one-liner that will do that for you: $ find . -maxdepth 1 -type d ! -name "." -print0 2>/dev/null \ | xargs -0 -I {} sh -c 'printf "%20s: %d\n" "{}" "$(find "{}" -maxdepth 1 -type f 2>...
Parallel and ls with white spaces
1,494,413,974,000
I am trying to execute simple 'parallel' command parallel -S server1,server2,server3 echo "Number {}: Running on \`hostname\`" ::: 1 2 3 It asks me for passwords to the three servers, but then nothing happens. Usual ssh to these servers works fine. Once I logged in to one of the servers, system warned me about failed...
"It asks me for passwords to the three servers" Looking at the documentation for GNU Parallel: "The sshlogin must not require a password" Since you are using the -S (--sshlogin) flag this is a problem. So you get asked for a password, this means GNU Parallel will not run. You need to set up ssh keys to ensure you can...
Using 'parallel' to execute command on remote hosts - nothing is returned, failed logins
1,494,413,974,000
I am learning GNU parallel and I wonder it this makes sense: bash: IFS=" " while read field || [ -n "$field" ]; do targets_array+=("$field") done </location/targets parallel -Dall bash myScript.sh ::: $targets_array I wonder if it makes sense because my output seem to stop at some point... I have 30.0...
$targets_array is equivalent to ${targets_array[0]}. To get all elements you need ${targets_array[@]}. And you should quote right. So it could be: parallel … ::: "${targets_array[@]}" # but don't parallel is an external command. If the array is large enough then you will hit argument list too long. Use ...
GNU parallel bash
1,516,741,576,000
I have a db of files to download containing fields for filename and download_url with the format: "foo-1.23.4.jar", "http://example.com/files/12345678/download" "bar-5.67.8.jar", "http://example.com/files/9876543/download" "baz-3.31.jar", "http://example.com/files/42424242/download" Where the urls tend to all be the ...
Concurrently with GNU parallel: parallel -a files_list.txt -j0 -C ", *" 'wget -q -O {1} {2}' -a input-file - use input-file as input source -j N - run up to N jobs in parallel. 0 means as many as possible -C regex - column separator. The input will be treated as a table with regexp separating the columns. The n'th ...
wget using -i with -O
1,516,741,576,000
I try to run cocurrent curl but it can easily report "Could not resolve host". To run curl parallel, I use "parallel". parallel :::: ./a.sh ./a.sh from api server % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Spee...
You should try using --dryrun when you are confused by what GNU Parallel runs: $ parallel --dryrun :::: ./a.sh ./a.sh #!/bin/bash #!/bin/bash #!/bin/bash #!/bin/bash curl http://127.0.0.1:81/a.php #!/bin/bash curl http://127.0.0.1:81/a.php curl http://127.0.0.1:81/a.php #!/bin/bash curl http://127.0.0.1:81/a.php c...
concurrent curl could not resolve host
1,516,741,576,000
I am taking two lists having filenames with paths and using gnu-parallel to process the files from the two lists. However,The command is able to use only files from the first list and not the second list,when I check my output.I have tried various options in this.e.g. giving the filetype in --readFilesIn (which is whe...
You are not telling GNU Parallel $reads_list and $reads_list2. So I am puzzled how you would expect GNU Parallel to guess that it should use these. By rsyncing in parallel as we go (instead of everything before running first job) it might be faster, too. My guess is that this is enough: parallel -j $NSLOTS --xapply \ ...
Reading two lists containing filenames
1,516,741,576,000
I have the following script which gets the absolute paths of some directories and pipes them into GNU parallel for zipping. I keep getting a signal 13 error and I'm not sure why. find $directory -maxdepth 1 | \ grep -v "^${directory}$" | \ xargs realpath | \ parallel -j 4 zip -r ${new_directory}/{/.}.zip {} The error...
Before getting to the actual failure that you're having, there are few things you need to fix in your command to handle some corner cases find "$directory" -maxdepth 1 -mindepth 1 -print0 | \ xargs -0 realpath | \ parallel -j 4 zip -r "$new_directory"/{/.}.zip {} The changes in find are: -mindepth 1 - this will excl...
Piping xargs into GNU parallel
1,516,741,576,000
I need to run an executable a large number of times, each time with two command line arguments. I've used to use xargs for this purpose, but lately I've been made aware of the existence of GNU parallel, which in principle seems like a better tool (more features, more up-to-date, more extensive documentation, etc.). Al...
You have hit one of the few incompatibilities between xargs and parallel which is by design. GNU Parallel will make sure the input is quoted as a single argument, whereas xargs will not. It was one of the original driving forces for writing the first versions of GNU Parallel. $ echo '9" nails in 10" boxes' | xargs ech...
Difference between xargs and GNU parallel
1,516,741,576,000
I want to use ffmpeg using two pc, i know parallel can do it I use this cli parallel --trc {.}.mkv -S virtual,: 'ffmpeg -y -i {} -vf yadif,crop=720:550:0:12,scale=640:352 -c:v libx264 -c:a aac -b:v 1500k -b:a 128k -metadata language=eng -metadata title="example" -aspect 16:9 {.}.mkv' ::: example.mpg It transfer the...
-S virtual,: will indeed make GNU Parallel spawn jobs both on the local machine (called :) and the server (virtual). In you example you only give one mpg-file as input. So given that, GNU Parallel will only run one job. In other words: GNU Parallel will not magically split your single mpg-file into multiple files and ...
Why my gnu parallel with ffmpeg execute ffmpeg only on remote host?
1,516,741,576,000
Let's say that I have 10 GBs of RAM and unlimited swap. I want to run 10 jobs in parallel (gnu parallel is an option but not the only one necessarily). These jobs progressively need more and more memory but they start small. These are CPU hungry jobs, each running at 1 core. For example, assume that each job runs for ...
Things have changed since June. Git version e81a0eba now has --memsuspend --memsuspend size (alpha testing) Suspend jobs when there is less than 2 * size memory free. The size can be postfixed with K, M, G, T, P, k, m, g, t, or p which would multiply the size with 1024, 1048576, 1073741824, 1099511627776, 11258999068...
parallel: Pausing (swapping out) long-running progress when above memory limit threshold
1,516,741,576,000
I created this script out of boredom with the sole purpose of using/testing GNU parallel so I know it's not particularly useful or optimized, but I have a script that will calculate all prime numbers up to n: #!/usr/bin/env bash isprime () { local n=$1 ((n==1)) && return 1 for ((i=2;i<n;i++)); do ...
GNU Parallel spends 2-10 ms overhead per job. It can be lowered a bit by using -u, but that means you may get output from different jobs mixed. GNU Parallel is not ideal if your jobs are in the ms range and runtime matters: The overhead will often be too big. You can spread the overhead to multiple cores by running mu...
How to optimize GNU parallel for this use?
1,516,741,576,000
I want to use variables as input while passing the arguments in GNU parallel. For instance, I have three bash scripts that I want to run in parallel using GNU parallel "par1.sh","par2.sh","par3.sh". my script look like this: Filecount=$(grep -c "if" $1) echo $Filecount parallel -j0 sh ::: par$(seq 1 $Filecount).sh ...
The issue isn't with parallel but with the "variable" you're passing. This is what par$(seq 1 $Filecount).sh will expand to (assuming that Filecount=10): $ echo par$(seq 1 $Filecount).sh par1 2 3 4 5 6 7 8 9 10.sh You want it to work like a brace expansion: $ echo par{1..10}.sh par1.sh par2.sh par3.sh par4.sh par5.sh...
Using variables as inputs in GNU parallel
1,516,741,576,000
I have a simple script that I want to copy and rename files, in files.lst based on a list of names in names.lst **name.lst** 100GV200.vcf 150GV200.vcf 14300GV200.vcf **file.lst** file1.txt file2.txt file3.txt My script so far looks like this: parallel --link -k "cp {} {}" :::: file.lst :::: name.lst Unfortunately I...
Use {1} and {2} notation: parallel --link -k cp {1} {2} :::: file.lst :::: name.lst Works for me, it will work with the quotes as well parallel --link -k "cp {1} {2}" :::: file.lst :::: name.lst To get it to work with {}, you would have had to do something like this: parallel --link -k "cp {}" :::: file.lst :::: nam...
Copying & Renaming Files with GNU Parallel
1,516,741,576,000
The following for loop runs thousands of jobs in parallel OSMSOURCE=europe-latest.o5m for SHAPEFILE in URBAN_[A-Z]*[0-9] ;do cd $SHAPEFILE for POLYGON in *.poly ;do osmconvert --drop-version $OSMSOURCE -B=$POLYGON --out-o5m > $(basename $OSMSOURCE .o5m |tr "-" "_")_$(basename $POLYGON .poly).o5m & ...
Well, GNU parallel will do the same and it's quite as easy to use. Its advantage is that it will take care of the number of CPU cores on your machine and by default it will not execute more jobs than that (*). Your program doesn't. If you have hundreds of .poly files, you will spawn hundreds of osmconvert jobs, which ...
Worth using parallel instead of forking processes in a for loop?
1,516,741,576,000
I am trying to copy files from machineB and machineC into machineA as I am running my below shell script on machineA. If the files is not there in machineB then it should be there in machineC for sure so I will try copying the files from machineB first, if it is not there in machineB then I will try copying the same f...
The error is typically caused by too many ssh/scp starting at the same time. That is a bit odd as you at most run 4. That leads me to believe /etc/ssh/sshd_config:MaxStartups and MaxSessions on $FILERS_LOCATION_1+2 is set too low. Luckily we can ask GNU Parallel to retry if a command fails: do_Copy() { el=$1 PRIMS...
How to copy in two folders simultaneously using GNU parallel by spawning multiple threads?
1,516,741,576,000
I have a below shell script from which I am trying to copy 5 files in parallel. I am running my below shell script on machineA which tries to copy the file from machineB and machineC. If the file is not there in machineB, then it should be there in machineC for sure. I am using GNU Parallel here to download five file...
Try exporting them and removing the array as bash can not export arrays: export PRIMARY=/data01/primary export FILERS_LOCATION_1=machineB export FILERS_LOCATION_2=machineC export MEMORY_MAPPED_LOCATION=/bexbat/data/be_t1_snapshot export dir1=/bexbat/data/be_t1_snapshot/20140501 Or simply put all the constant variabl...
Variable value is not recognized after using gnu parallel?
1,516,741,576,000
I have a very large SQL dumpfile (30GB) that I need to edit (do some find/replace) before loading back into the database. Besides having a large size, the file also contains very long lines. Except for the first 40 and last 12 lines, all other lines have lenghts ~ 1MB. These lines are all INSERTO INTO commands that al...
You should be using --pipe (or --pipepart). If your disks are fast: parallel -a bigdumpfile.sql --pipe-part --block 100M -k -q sed 's/table1/newtable/' | sql ... If they are slow: parallel -j1 -a bigdumpfile.sql --pipe-part --block 100M -k -q sed 's/table1/newtable/' | sql ... Adjust -j to find the best for your dis...
Use GNU parallel with very long lines
1,516,741,576,000
Scenario: $ cat libs.txt lib.a lib1.a $ cat t1a.sh f1() { local lib=$1 stdbuf -o0 printf "job for $lib started\n" sleep 2 stdbuf -o0 printf "job for $lib done\n" } export -f f1 cat libs.txt | SHELL=$(type -p bash) parallel --jobs 2 f1 Invocation and output: $ time bash t1a.sh job for ...
From the man pages of GNU parallel: --group Group output. Output from each job is grouped together and is only printed when the command is finished. Stdout (standard output) first followed by stderr (standard error). This takes in the order of 0.5ms CPU time per job and depends on the speed of your disk for larger ou...
GNU parallel: why does diagnostic output look like sequential execution rather than parallel execution?
1,516,741,576,000
Consider the data from the GNU parallel manual's example for --group-by: cat > table.csv <<"EOF" UserID, Consumption 123, 1 123, 2 12-3, 1 221, 3 221, 1 2/21, 5 EOF Is there a way to group records by one column and write all the values from another column in the group as command-line arguments? This c...
In Bash you can do: doit() { parallel --header : --colsep , -n4 echo UserID {1} Consumption {2} {4} {6} {8}; } export -f doit cat table.csv | parallel --pipe --colsep , --header : --group-by UserID -kN1 doit I do not see you can do it in a single parallel instance. What you want is to mix --pipe and normal mode, and ...
Can I use GNU parallel to group command arguments by a column value?
1,516,741,576,000
I want to run some script over powers of two in parallel. Doing so by giving GNU Parallel a list of the powers of two I want works well: %>parallel echo {} ::: 32, 64, 128, 256, 512, 1024 32 64 128 256 512 1024 %> I can also give GNU Parallel a range of values without issue: %>parallel echo {} ::: {5..10} 5 6 7 8 9 1...
You need to quote the entire command being run by parallel, for example: $ parallel 'echo $((2**{}))' ::: {5..10} 32 64 128 256 512 1024 Actually, just quoting the bash arithmetic part of the command works too: $ parallel echo '$((2**{}))' ::: {5..10} 32 64 128 256 512 1024 The reason is that without quotes, bash wi...
Arithmetic with GNU parallel
1,516,741,576,000
GNU Parallel worked fine and suddenly whenever I try to use it I am getting this error message I am getting while running any parallel command: parallel: This should not happen. You have found a bug. Please contact <[email protected]> and include: * The version number: 20160222 * The bugid: pidtable format: 10390 1 ...
20160222 is 4 years old. It is a known problem. Upgrade to 20201222
GNU Parallel stopped working
1,516,741,576,000
I have a large dataset (>200k files) that I would like to process (convert files into another format). The algorithm is mostly single-threaded, so it would be natural to use parallel processing. However, I want to do an unusual thing. Each file can be converted using one of two methods (CPU- and GPU-based), and I woul...
Something like this: gpus=2 find files | parallel -j +$gpus '{= $_ = slot() > '$gpus' ? "foo" : "bar" =}' {} Less scary: parallel -j +$gpus '{= if(slot() > '$gpus') { $_ = "foo" } else { $_ = "bar" } =}' {} -j +$gpus Run one job per CPU thread + $gpus {= ... =} Use perl cod...
Process multiple inputs with multiple equivalent commands (multiple thread pools) in GNU parallel
1,516,741,576,000
As in title. I've got a lot of ZIP archives that I want to extract. All archives have their own unique name. All archives contain files only (inside archives there are NOT folder(s) at all: no parent / main folder). I'd like to process all these ZIP archives via GNU parallel. To sum up: archivename(s).zip has NOT fol...
Removing file extension when processing files: parallel 'mkdir {.} && cd {.} && unzip ../{}' ::: *.zip
GNU parallel + gunzip (or 7z, or bsdtar, or unzip): extract every "archivename.zip" into (to-be-created) its "archivename" subfolder
1,516,741,576,000
Not being a perl programmer I'm thinking this would be fairly easy with --tagstring, but basically I'd like to time-stamp each line of output from each job individually from Parallel. Something like, with the right replacement for “STUFF”, the output may look like, assuming millisecond resolution (although nanosecond ...
You would deceptively think that is easy, and I can't blame you for that. It is, however, not possible for normal output. This is because the tagstring is only computed twice, and it is only added after the job is completed. GNU Parallel runs: job1 > tmpout1 2> tmperr1 job2 > tmpout2 2> tmperr2 job3 > tmpout3 2> tmper...
GNU Parallel time stamp output
1,516,741,576,000
I am attempting to look into multiple subdirectories within a single directory, and plot the files in each subdirectory using a python script that I am calling within this bash script using gnu-parallel. The arguments the python script takes are -p: path to files (i.e. the subdirectory) and -o: outpath for plots (whic...
I don't think $pat and $out have the values you think they do $ echo ${files[@]} ./d1/file1 ./d1/file2 ./d1/file3 ./d2/file4 ./d2/file5 ./d2/file6 $ pat=$files $ echo ${pat[@]} ./d1/file1 $ out=$files $ echo ${pat[@]} ./d1/file1 I think what you're trying to accomplish requires different values for $pat and $out depe...
How can I recursively find directories and parse them into python script call within bash script?
1,516,741,576,000
I am running a command line software on multiple folder/samples.Each folder has such files *fastq.gz. Below is an example of a folder. Sample_EC_only/EC_only_S1_L005_I1_001.fastq.gz Sample_EC_only/EC_only_S1_L005_R1_001.fastq.gz Sample_EC_only/EC_only_S1_L005_R2_001.fastq.gz Sample_EC_only/EC_only_S1_L006_I1_001.fastq...
If I understand you correctly, all you are looking for is {1/} instead of {1}. It is the "basename" of the argument. See man parallel_tutorial and the discussion of --rpl where we have that replacement strings are implemented as --rpl '{/} s:.*/::' and The positional replacement strings can also be modified usi...
Extract the pattern of Directory in GNU parallel
1,516,741,576,000
Suppose I have a file "Analysis.C" which takes a data file as input. The data file is named as "a.00001.txt" through "a.01000.txt". One way to loop over all the files is to write a shell script where I use sed to change the input file name in "Analysis.C" over an iteration from 0001 to 1000. However, I have to do this...
With GNU Parallel you can do this: parallel analysis.C ::: *.txt Or if you have really many .txt-files: printf '%s\0' *.txt | parallel -0 analysis.C It will default to run one job per CPU thread. This can be adjusted with -j20 for 20 jobs in parallel. Contrary to the parallel.moreutils-solution you can post process ...
Parallely running multiple copies of the same file with different inputs using shell script
1,516,741,576,000
I have the following zip archive structure: $ unzip -l Undetermined_S0_L004_R1_001_fastqc.zip Archive: Undetermined_S0_L004_R1_001_fastqc.zip Length Date Time Name -------- ---- ---- ---- 0 10-10-14 14:44 Undetermined_S0_L004_R1_001_fastqc/ 0 10-10-14 14:44 Undetermined_S0_L...
You have a pipeline made of four commands: find, which lists zip files. parallel, which invokes unzip to extract one file in each zip file. Given that {} is replaced by the path to the zip file, you attempt to extract files like home/user977828/stuff/Undetermined_S0_L004_R1_001_fastqc.zip/fastqc_data.txt from the arc...
Parallel read the contents of a zipped file without extraction
1,516,741,576,000
I tried to use parallel command in the following way: cat asm.contig.fasta | parallel -k --block 1k --recstart '>' --pipe 'blat -t=dnax -q=prot - ../swissprot.fasta out{#}.psl -noHead' but unfortunately I got this error: mustOpen: Can't open - to read: No such file or directory What did I do wrong?
The error is not from GNU Parallel, so it is from blat. I have not used blat for years, so I am not 100% sure of the following. My guess is that you cannot use use - to denote STDIN for the database in blat. There are several ways of tickling blat. Use /dev/stdin which will give the standard input as a fifo on many sy...
Parallel caused this "error mustOpen: Can't open - to read: No such file or directory"
1,516,741,576,000
I have 4 cores, and 4 python script files preprocess0.py, preprocess1.py, preprocess2.py, preprocess3.py. I would like to run these 4 processes in parallel using GNU parallel. I do not have input files. The input file is hardcoded inside each *.py file (it's read only, so it's ok). I would like to output the results t...
The syntax is: parallel -j4 --progress 'python {} > ./file{}.csv' ::: preprocess*.py That would create files called filepreprocess1.py.csv... You could use parallel -j4 --progress 'python {} > ./file{#}.csv' ::: preprocess*.py instead to use the job number instead and get some file1.csv... files. Or if you want to e...
gnu parallel with no argument script
1,516,741,576,000
When I run the following command: parallel --max-procs 4 echo ::: {1..4} in my PC, it produces the expected output, 1, 2, 3, 4 (in different lines). However, when I run the same command on another computer (which has parallel installed), it doesn't produce output. Both PCs have Ubuntu 14.04 installed (the one where ...
It turns out that I had zero free disk space on the PC that was giving trouble! Maybe this is too specific, but I am going to leave this here anyway, in case someone else runs into a similar problem.
parallel --max-procs 4 echo ::: {1..4} produces no output?
1,516,741,576,000
How can I get reasonable parallelisation on multi-core nodes without saturating resources? As in many other similar questions, the question is really how to learn to tweak GNU Parallel to get reasonable performance. In the following example, I can't get to run processes in parallel without saturating resources or ever...
To debug this I will suggest you first run this with something simpler than gdalmerge_and_clean. Try: seq 100 | parallel 'seq {} 100000000 | gzip | wc -c' Does this correctly run one job per CPU thread? seq 100 | parallel -j 95% 'seq {} 100000000 | gzip | wc -c' Does this correctly run 19 jobs for every 20 CPU threa...
GNU Parallel with -j -N still uses one CPU
1,516,741,576,000
I've several files containg POST body requests. I'd like to send those requests in parallel. Related curl command is like: curl -s -X POST $FHIR_SERVER/ -H "Content-Type: application/fhir+json" --data "@patient-bundle-01.json" Request bodies are files like patient-bundle-xx, where xx is a number. Currently, I'd like ...
With GNU Parallel: doit() { bundle="$1" curl -s -X POST $FHIR_SERVER/ -H "Content-Type: application/fhir+json" --data "@patient-bundle-$bundle.json" } export -f doit export FHIR_SERVER seq -w 99 | parallel -j77 doit Adjust -j77 if you do not want 77 jobs in parallel.
Make parallel http requests using raw data files
1,516,741,576,000
I pass the variables from a script to the main script in a parallel command like ./script1 | parallel -u --jobs 3 "./script2 {}" How can I pass the job number as the second argument of ./script2? something like ./script1 | parallel -u --jobs 3 "./script2 {} {}" ::: {1..3} but the first {} should come from ./script1....
You are most likely looking for {%} which is not the job number, but the job slot number. LC_ALL=C seq 10 -0.1 1 | shuf | parallel --lb 'echo Job {} grabs {%}; sleep {}; echo Job {} releases {%}' Notice how when a number is released it is grabbed by the next job. So no 2 jobs running in parallel will have the same ...
How to pass job number in GNU Parallel?
1,516,741,576,000
I am copying files from remote server to my local server using below scp command. I just type below command on the terminal and it starts copying. scp -r user@machineA:/data/process/* /data/process/ Now since on remote servers we have around 100 files and each file size is around 11 GB so above command will copy one ...
Here's the command to be run on the remote server, involving find and parallel: find /data/process/ -type f | parallel scp {} user@machineB:/data/process/ Edit: See the documentation on how to control the number of jobs to be executed in parallel. The number of concurrent jobs is given with --jobs or the equivalent ...
Copy files in parallel from remote servers using some command on terminal?
1,516,741,576,000
If I have already started a job with GNU parallel in a similar fashion to: $ cat jobs | parallel -j 70 "program {};" is it possible, by e.g. some signal, to adjust the number of jobs of this parallel job? So that I could indicate to parallel that there should now be run at most 75 sub-jobs?
ERROR: type should be string, got "\nhttps://www.gnu.org/software/parallel/parallel_tutorial.html#Number-of-simultaneous-jobs\n\nNumber of simultaneous jobs\n:\n--jobs can read from a file which is re-read when a job finishes:\necho 50% > my_jobs\n/usr/bin/time parallel -N0 --jobs my_jobs sleep 1 :::: num128 &\nsleep 1\necho 0 > my_jobs\nwait\n\nThe first second\nonly 50% of the CPU cores will run a job. Then 0 is put into my_jobs\nand then the rest of the jobs will be started in parallel.\n\nI highly recommend spending an hour walking through the tutorial. Your command line will love you for it.\n"
Is it possible to adjust number of sub-jobs for GNU parallel after invocation?
1,516,741,576,000
Due to my lack of Bash knowledge I've tried for a few hours now to get something like this to work: find Directories -mindepth 4 -type d -print0 | parallel -0 -j0 ./MyScript -d {Found Directory} {1} ::: a b c d Where a,b,c and d are different arguments that my script needs to execute commands (in my case being -rb, -...
find Directories -mindepth 4 -type d -print0 | parallel -0 -j0 ./MyScript -d {2} {1} ::: a b c d :::: -
Find | parallel executing script with path from find + other arguments
1,516,741,576,000
My scripts are having trouble with correctly running things in GNU parallel. I have a sub_script like so (all these are actually simplified versions): #! /bin/bash input=$1 # input is a date in YYYYMMDD format mkdir -p $input cd $input filename=$input'.txt' echo 'line1' > $filename echo 'The date is: '$i...
Why the extra batchfile, if you use parallel? parallel -j3 --delay 1 ./sub_script ::: 20141001 20141002 20141003 20141004 20141005
Concurrency problems with GNU parallel
1,516,741,576,000
I have a short script that uses scp to copy files to a number of remote hosts (yes, I know about rdist and rsync; they both fail to work for a few of the hosts - that's not the point here; I'm only copying a few non-critical files anyway). The meat of the script looks something like this: for h in $HOSTS; do echo ...
To trick scp into thinking it has a tty connected you can use script: script -c 'scp foo server1:/bar/' So to run that in with parallel you need something like: parallel -j30 "echo {}; echo '----------------------------------------' ; script -c 'scp -r $FILES {}:' ; echo ''" ::: $HOSTS To learn more check out the ...
scp does not display output when used with gnu parallel
1,582,061,970,000
I would like the timing pause to be replaced with the equivalent of a getchar() in a GNU parallel execution: parallel -j2 --halt 2 ::: 'sleep 5m; return 1' './runMe' However the following does not work (it finishes the execution of the first job immediately): parallel -j2 --halt 2 ::: 'read -n1 kbd; return 1' '/runMe...
GNU Parallel can run interactively using -p. parallel -p echo ::: 1 2 3 You will have to answer y every time, but maybe that is good enough. Also be aware that any output will be delayed. When running 3 jobs in parallel, the output of job 1 will be printed after starting job 3.
Pausing in GNU parallel and waiting for character
1,582,061,970,000
I trying to run command recon-all with GNU parallel freesurfer preproc i have a bash array of list of patients to run 8 patents simultaneously: root@4d8896dfec6c:/tmp# echo ${ids[@]} G001 G002 G003 G004 G005 G006 G007 G008 and try to run with command: echo ${ids[@]} | parallel --jobs 28 recon-all -s {.} -all -qcache ...
The problem is that parallel wants the input to be separated by newlines but when you use echo it is separated by spaces. In order to print some words separated by newlines you can try one of these echo one two three | tr ' ' '\n' # in case your input can not be controlled by you printf '%s\n' one two three ...
gnu parallel with bash array
1,582,061,970,000
I'm learning GNU parallel and tried the following: $ for i in {1.txt,2.txt}; do time wc -l $i; done 100 1.txt real 0m0.010s user 0m0.000s sys 0m0.010s 10000012 2.txt real 0m0.069s user 0m0.050s sys 0m0.018s I then reran the above command with parallel, but it slowed things down. Why? $ for i in ...
In your case you're calling it from a for loop so you aren't really running anything in parallel. All you're doing is adding the overhead of calling parallel in the second example, but it's still only running the files through in a single fashion. Example This might help you see what's going on. without parallel $ tim...
Why does GNU Parallel slow down?
1,582,061,970,000
I am running GNU parallel and after some time I am getting: parallel: Warning: no more file handles Raising ulimit -n or etc/security/limits.conf may help. What argument would be appropriate to add to the parallel command in order to overcome this? I changed limits.conf to unlimited but then I could not use sudo or l...
To avoid having tmp files laying around after abnormal termination (think kill -9 or system crash), GNU Parallel opens tmp files and removes them immediately. But it keeps the files open. To meet the requirement of --keep-order it has to keep all the files open that have not been printed yet. So if you have 1000000 co...
parallel: Warning: No more file handles
1,582,061,970,000
I would like to speed up my archiving operations, I am usually doing 23 GiB (one Blu-Ray) backups. I have found this: How to do large file parallel encryption using GnuPG and GNU parallel? Since I don't understand this code at all (have never used parallel): tar --create --format=posix --preserve-permissions --same-o...
tar run command tar. --create create a tar archive. --format=posix use the POSIX format of tar archive. This means you can extract it on other systems that support the POSIX format. --preserve-permissions keep the same permissions on the files --same-owner keep the same owner of the file (only relevant when extracting...
GNU parallel proper usage in conjunction with tar, xz, gpg
1,582,061,970,000
I want to parallelize spliting of many directories into subdirectories using parallel or using another tool or method. E.g. I have 1 000 000 directories with content, but it's too much for one directory, so I want to create 10 dirs in the main dir and move in each of them 100 000 original dirs. I also want to use sor...
This problem deals with heavy IO. I doubt that parallel is really useful in this situation. Anyway I suggest that you consider a "traditional" approach: mkdir dir_{1..10} ls -tr | nl | \ awk '$2 !~ /^dir_/ {i=1+int($1/100000); print $2 | "xargs mv -t dir_"i}' where ls -tr | nl sorts the directories by date an...
Use parallel to split many directories into subdirectories or parallelize this task
1,582,061,970,000
I'm trying to use GNU Parallel to run a command for each input argument, using that argument as the command's working directory (without appending it to the command line). Basically, what I need to do is: /foo -> "cd /foo; mycmd" /bar -> "cd /bar; mycmd" /baz -> "cd /baz; mycmd" Parallel has --workdir which seems to...
I believe the easiest would be: printf '%s\n' $HOME/{foo,bar,baz} | parallel 'cd {} && myprg' You can use --workdir, but it is clearly not meant for this situation. GNU Parallel normally wants a replacement string in the command template, and you want {} to contain the argument for --workdir. Using -n0 will not help,...
Use each input argument in GNU Parallel as a working directory
1,582,061,970,000
#!/usr/bin/bash TARGETS=( "81.176.235.2" "81.176.70.2" "78.41.109.7" ) myIPs=( "185.164.100.1" "185.164.100.2" "185.164.100.3" "185.164.100.4" "185.164.100.5" ) for t in "${TARGETS[@]}" do for a in "${myIPs[@]}" do echo "${a} ${t} -p 80" >>log 2>&1 & echo "${a} ${t} -p 443" >>log 2>&1 & ...
I find your question hard to understand: you seem to want both parallel and sequential execution. Do you want this? for t in "${TARGETS[@]}"; do ( for a in "${myIPs[@]}"; do echo "${a} ${t} -p 80" >>log 2>&1 & echo "${a} ${t} -p 443" >>log 2>&1 & wait done ) & done each target's for ...
How might I execute this nested for loop in parallel?
1,582,061,970,000
With this loop we sequential update on all servers (server list = consul members | grep awk {'print $2'} | cut -d ":" -f1) the package consul. for i in $(consul members | grep awk {'print $2'} | cut -d ":" -f1) ; do sshpass -p $PASSWORD ssh -oStrictHostKeyChecking=no -q root@$i "hostname && yum clean all && yum -y upd...
Indeed, pssh sounds like the better solution. If you must use parallel it should be fairly simple: pipe the hostnames one per line into a single command that uses {} as a placehold. Eg: consul members | ... awk {'print $2'} | cut -d ":" -f1 | parallel -j 10 sshpass -p "$PASSWORD" ssh -oStrictHostKeyChecking=no -q root...
GNU Parallel and sshpass with server list in a loop
1,582,061,970,000
Scenario: $ process(){ echo "[$1] [$2] [$3]" ; } ; export -f process $ process "x" "" "a.txt" [x] [] [a.txt] Here we see that the 2nd argument is empty string (expected). $ find -name "*.txt" -print | SHELL=$(type -p bash) parallel process "x" "" [x] [./a.txt] [] [x] [./b.txt] [] [x] [./c.txt] [] Here we see that t...
So, parallel runs the command through a shell, instead of executing it directly. Well, it has to, since otherwise the shell function you're using wouldn't work. It also means that arguments with whitespace will get split: $ echo x | parallel process "foo bar" "" [foo] [bar] [x] And it doesn't really matter if you quo...
GNU parallel: how to call exported bash function with empty string argument?
1,582,061,970,000
I use GNU Parallel along a for loop like this: for BAND in $(seq 1 "$BANDS") ;do # Do not extract, unscale and merge if the scaled map exists already! SCALED_MAP="era5_and_land_${VARIABLE}_${YEAR}_band_${BAND}_merged_scaled.nc" MERGED_MAP="era5_and_land_${VARIABLE}_${YEAR}_band_${BAND}_merged.nc" if [ ! -f...
--joblog only adds to the joblog when the job is finished. You are giving GNU Parallel two jobs: log ... gdalmerge_and_clean ... log finishes fast and is added to joblog, but gdalmerge_and_clean probably takes longer to run. I think you should consider rewriting your job as a function and call that: doit() { BAND=...
GNU Parallel --joblog logs only first line of commands inside a for loop
1,582,061,970,000
I'm working on a computer with 10k cores, but only allowed to access 1,000 at a time. I have a script that could benefit from GNU parallel in multiple places. Processing level A in parallel, and within that script, do something 30x. It will take a lot of work to re-write the entire script to use the parallel --link an...
If I understand correctly, you want to run 2 (or more instances) of GNU Parallel, and you want the total number of running jobs to be <1000. So at some point one of the may run 300 jobs, then the other should limit to 700 jobs. --limit is made for this kind of specialized situation: It will run a script of your choice...
Limit total number of GNU-parallel jobs between mutliple calls
1,582,061,970,000
I am trying to download multiple files parallelly in bash and I came across GNU parallel. It looks very simple and straight forward. But I am having a hard time getting GNU parallel working. What am I doing wrong? Any pointers are appreciated. As you can see the output is very sequential and I expect output to be diff...
parallel output is sequential because it captures the processes output and prints it only when that process is finished, unlike xargs which let the processes print the output immediately. From man parallel GNU parallel makes sure output from the commands is the same output as you would get had you run the comman...
Bash parallel command is executing commands sequentially
1,582,061,970,000
I made a Python simulator that runs on the basis of user-provided arguments. To use the program, I run multiple random simulations (controlled with a seed value). I use GNU parallel to run the simulator with arguments in a similar manner as shown below: parallel 'run-sim --seed {1} --power {2}' ::: <seed args> ::: <po...
For part of the answer you want this, correct? $ parallel --link -k echo {1} {2} ::: {0..3} ::: {100..450..50} 0 100 1 150 2 200 3 250 0 300 1 350 2 400 3 450 If so, one way to do what I think you want would be $ parallel -k echo {1} {2} ::: {10..20..10} ::: "$(parallel --link -k echo {1} {2} ::: {0..3} ::: {100..450...
GNU Parallel linking arguments with alternating arguments
1,582,061,970,000
Currently I have the following script for using the HaploTypeCaller program on my Unix system on a repeatable environment I created: #!/bin/bash #parallel call SNPs with chromosomes by GATK for i in 1 2 3 4 5 6 7 do for o in A B D do for u in _part1 _part2 do (gatk HaplotypeCaller \ -R /stor...
parallel echo HaploSample.chr{1}{2}{3}.raw.vcf ::: 1 2 3 4 5 6 7 ::: A B D ::: _part1 _part2
Converting for loops on script that is called by another script into GNU parallel commands
1,582,061,970,000
I tried performing the full installation from: http://git.savannah.gnu.org/cgit/parallel.git/tree/README The installation was successful. It's working well when installed on Mac OS but on Amazon Linux (RHEL64) I am facing below issues: On running just parallel the command exits silently. dev-dsk % parallel dev-dsk % ...
Not sure why it was not working as for me there was just one executable named parallel in my system path. But I was able to fix it as below: Run whereis parallel. This gives all the paths where executables named parallel is present. For my case there was just one path /usr/local/bin/parallel. Running using this path ...
GNU Parallel facing silent exit and invalid option error
1,582,061,970,000
I want to run a task where I specify two commands which will be run in an alternating fashion with different parameters. E.g: 1. exec --foo $inputfile1 $inputfile.outfile1 2. exec --bar $inputfile2 $inputfile.outfile2 3. exec --foo $inputfile3 $inputfile.outfile3 4. exec --bar $inputfile4 $inputfile.outfile4 I could ...
You can first put all parameters in a file and then use parallel -a filename command For example: echo "--fullscreen $(find /tmp -name *MAY*.pdf) $(find /tmp -name *MAY*.pdf).out" >> /tmp/a echo "--page-label=3 $(find /tmp -name *MAY*.pdf) $(find /tmp -name *JUNE*.pdf).out" >> /tmp/a echo "--fullscreen $(find /tmp ...
GNU Parallel alternating jobs
1,582,061,970,000
I want to print the filename/s together with the matching pattern but only once even if the pattern match has multiple occurrence in the file. E.g. I have a list of patterns; list_of_patterns.txt and the directory I need to find the files is /path/to/files/*. list_of_patterns.txt: A B C D E /path/to/files/ /file1 /fi...
Is there a better way to speedup the process? Yes, it's called GNU parallel: parallel -j0 -k "grep -Hof list_of_patterns.txt {} | sort -u" ::: /path/to/files/* j N - number of jobslots. Run up to N jobs in parallel. 0 means as many as possible. k (--keep-order) - keep sequence of output same as the order of input ...
How to print only 1 filename together with the matching pattern?
1,582,061,970,000
I have a process like this that generates a predefined number of files but at random intervals: #!/bin/bash for i in {1..10} do sleep $(shuf -i 20-60 -n 1) echo $i > file_$i.txt done I have another process that runs on each of those files independently using GNU Parallel like so: parallel wc -l ::: file_{1..10}....
Look at https://www.gnu.org/software/parallel/parallel_examples.html#example-gnu-parallel-as-queue-system-batch-manager Terminal 1: true >jobqueue; tail -n+0 -f jobqueue | parallel -u (-u is needed if you want output on screen immediately. Otherwise the output will be delayed until the next job completes. In both cas...
GNU Parallel: Run while partial files available and wait for the rest
1,582,061,970,000
To set the stage, here is an example file structure: test/1 test/2 test/3 I want to do this: find -P -O3 "test/" -type f | parallel --use-cpus-instead-of-cores -j+0 --tmpdir "test/" --files ./test.bash And pass another manual parameter to test.bash such that if it is: #!/usr/bin/env bash main() { echo "yay $1...
This is a bit unsafe, because file names can contain delimiters (newlines): find -P -O3 test/ -type f \ | parallel -j+0 --use-cpus-instead-of-cores \ --tmpdir test/ \ --files \ -m ./test.bash {} 'param' use instead: find -P -O3 test/ -type f --print0 \ | parallel -0 \ -j+0 ...
Passing parameters to GNU Parallel manually and by piping