Tag Info

New answers tagged

3

I assume you're not describing your real-world scenario: not only do you want to copy hundreds of thousands of files, but you want to sleep for hundreds of thousands of seconds... wtf?!? Anyway: while IFS= read -r file1 IFS= read -r file2 do cp "$file1" "${file1##*/}-backup" cp "$file2" "${file2##*/}-backup" sleep 1 done < inputFile


1

Sorry: I have not noticed the "txt file" with the "hundreds thousands of lines". This is just a naif solution... for a in test*; do ls -l $a; if [[ $((i++ % 2)) != 0 ]]; then sleep 1; fi; done Update: Explanation and (partially update to txt file with filenames). ...reformating: for a in `cat file.txt` do cp "$a" "$a-backup" ## REPLACE ...


0

Apply the changes directly to a running process if you have prlimit installed (comes with util-linux-2.21) prlimit --pid <pid> --<limit>=<soft>:<hard> for example prlimit --pid 12345 --nofile=1024:2048 Refer here


1

Split urls into one file per host. Then run 'parallel -j5' on each file. Or sort urls and insert a delimiter '\0' when a new host is met, then split on '\0' and remove '\0' while passing that as a block to a new instance of parallel: sort urls.txt | perl -pe '(not m://$last:) and print "\0";m://([^/]+): and $last=$1' | parallel -j10 --pipe --rrs -N1 ...


6

The timeout command will do this for you, i.e. timeout 10s command It will kill command after 10 seconds. Instead of s for seconds, you can also use m for minutes, h for hours or d for days.


0

nice / renice nice is a great tool for 'one off' tweaks to a system. nice COMMAND cpulimit cpulimit if you need to run a CPU intensive job and having free CPU time is essential for the responsiveness of a system. cpulimit -l 50 COMMAND cgroups cgroups apply limits to a set of processes, rather than to just one cgcreate -g cpu:/cpulimited cgset -r ...


1

For a large or a considerable range of ip's my recommendation for you is use ipset If want to block an entire country ip block you can use the geoip module for iptables.



Top 50 recent answers are included