0

I have a command which is checkReplace test.txt and would like to assign more CPU and memory to this line of command (which I wrote it in a shell script for automation). Since the test.txt could be huge (10GB etc), anyone here could kindly suggest me how to increase the CPU and memory allocation to this command so as to increase the writing speed of test.txt (I suppose). Kindly advice, thanks

2 Answers 2

2

You can start the command with higher CPU priority by simply starting it with the nice command, like so:

# nice -n -20 checkReplace test.txt

The highest possible priority is -20, with the default being 0. However, unless you're running other heavily CPU intensive processes, I can't imagine increasing CPU priority of a process will help it write to disk too much faster. That depends largely on hard drive write speeds, etc.

Sign up to request clarification or add additional context in comments.

3 Comments

I mean is there any command that would increase the cpu usage to a fixed value such as I want my `checkReplace test.txt' to be run at 50% of CPU all the time. Is there any?
@CheeHowWee No there is not. The process will take up whatever it needs. You can set limits if it's taking up too much CPU or you can adjust process priority as this answer states. You can't make it take up more CPU than it needs. What would it be doing exactly? Just wasting cycles.
Oh, and if it's writing a large file then the CPU isn't going to be your bottlenck. The HDD is. And there's no real solution for that bottleneck without spending money on a faster drive.
2

If checkReplace is a shell script then re-writing it in another scripting language (python, perl, ruby, ...) or in a real programming language would significantly improve it's speed. Shell scripts are mainly for simple tasks. But if you need heavy computations or I/O operations they are usually way to inefficient.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.