How do I throttle a command in a terminal window?

To Do

I needed to run convert with a lot of images at the same time. The command took quite a while but this doesn't bother me.

The issue is that this command rendered my computer unusable while the command was running (for about 15 minutes).

So is it possible to throttle the command by limiting resources (processor and memory) to the command, directly from the command line? This can only work if I add something to the same line before pressing Enter because once I start the process the computer slows so much that it is impossible for example to switch to "System monitor" and reduce priority.

Edit: top and iotop results

I managed to run top and sudo iotop >iotop.txt while doing one of these convert operations. (The iotop.txt file produced is difficult to read)

Results of top:

   PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND           
14275 username     20   0 4043m 3.0g 1448 D   7.0 80.4   0:16.45 convert 

Results of iotop:

[?1049h[1;24r(B[m[4l[?7h[?1h=[39;49m[?25l[39;49m(B[m[H[2JTotal DISK READ:    1269.04 K/s | Total DISK WRITE:[59G0.00 B/s
(B[0;7m  TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN(B[0;1;7m     IO>(B[0;7m    COMMAND          [3;2H(B[m2516 be/4 username     350.08 K/s    0.00 B/s  0.00 %  0.00 % zeitgeist-datahub
 7394 be/4 username     568.88 K/s    0.00 B/s 77.41 %  0.00 % --rendere~.530483991[5;1H14275 idle username     350.08 K/s    0.00 B/s 37.49 %  0.00 % convert S~f test.pdf[6;2H2048 be/4 root[6;24H0.00 B/s    0.00 B/s  0.00 %  0.00 % [kworker/3:2]
[5G1 be/4 root[7;24H0.00 B/s    0.00 B/s  0.00 %  0.00 % init

Furthermore, even after the process ends, the computer does not return to the previous performance. I found a way around this by running sudo swapoff -a followed by sudo swapon -a

Jim Salter

Oh, boy, I just caught this... quoting OP:

Furthermore, even after the process ends, the computer does not return to the previous performance. I found a way around this by running sudo swapoff -a followed by sudo swapon -a

OK, so that means you were exhausting the available RAM on your system, which means you're just plain trying to run too many convert processes at once. We'd need to look at your actual syntax in spawning convert to advise, but basically, you need to make sure you don't try to open more simultaneous processes than you have the RAM to comfortably handle.

Since you state what's causing this is convert *.tif blah.pdf, what's happening is that the content of every single TIF and its conversion to PDF are getting stuffed into RAM at once. What you need to do is split the job up so that this isn't necessary. One possibility that leaps to mind is instead doing something like find . -iname '*.tif' | xargs -I% convert % %.pdf, then using pdftk or something like it to glue all the individual pdfs together. If you really want to get fancy, and you have a multicore CPU, this also affords you the chance to write a small script to run conversions in batches of n, where n is your number of cores, and get the whole thing done significantly faster. :)

pdftk how-to: http://ubuntuhowtos.com/howtos/merge_pdf_files (basically boils down to sudo apt-get install pdftk; pdftk *.pdf cat output merged.pdf)

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How do I throttle how frequently lines of output are passed on?

분류에서Dev

How do I detect if I'm in a 'full screen' bash shell or GUI terminal window?

분류에서Dev

How can I open a terminal window on OSX?

분류에서Dev

How do I determine the number of rows and columns in a gnome-terminal window while resizing?

분류에서Dev

How to redraw terminal window after wall command displays message

분류에서Dev

How do I see all previous output from a completed terminal command?

분류에서Dev

How can I throttle stack of api requests?

분류에서Dev

How do I lock the terminal screen from the terminal?

분류에서Dev

How do I get root in terminal?

분류에서Dev

How do I unminimize a weston window?

분류에서Dev

Command to open new terminal window from the current terminal?

분류에서Dev

How do I look at the source code for a command?

분류에서Dev

How do I set the at command shell to bash?

분류에서Dev

How do I periodically reload a web page in a Terminal web browser?

분류에서Dev

How do I use pushd and popd commands in Terminal?

분류에서Dev

How do I resume an upgrade after pressing d for details in terminal?

분류에서Dev

How do I permanently enable terminal output to a file?

분류에서Dev

How do I install and use PyCharm without having to use a terminal?

분류에서Dev

How do I install and use PyCharm without having to use a terminal?

분류에서Dev

How do I respond to a terminal prompt before it is asked?

분류에서Dev

How to pass a terminal command as an argument to another command

분류에서Dev

How do I control window placement in KDE with keyboard?

분류에서Dev

How do I launch a remote firefox window via SSH?

분류에서Dev

How do I block the window.on('beforeUnload') event for <a> tag?

분류에서Dev

In Xcode how do I get files to open in the same window

분류에서Dev

how do I detect if window.location failed?

분류에서Dev

How do I repair a broken Skype group chat (window)?

분류에서Dev

How do I stop the animated movement of an object at the edge of the window?

분류에서Dev

How do I force a tmux window to be a given size

Related 관련 기사

  1. 1

    How do I throttle how frequently lines of output are passed on?

  2. 2

    How do I detect if I'm in a 'full screen' bash shell or GUI terminal window?

  3. 3

    How can I open a terminal window on OSX?

  4. 4

    How do I determine the number of rows and columns in a gnome-terminal window while resizing?

  5. 5

    How to redraw terminal window after wall command displays message

  6. 6

    How do I see all previous output from a completed terminal command?

  7. 7

    How can I throttle stack of api requests?

  8. 8

    How do I lock the terminal screen from the terminal?

  9. 9

    How do I get root in terminal?

  10. 10

    How do I unminimize a weston window?

  11. 11

    Command to open new terminal window from the current terminal?

  12. 12

    How do I look at the source code for a command?

  13. 13

    How do I set the at command shell to bash?

  14. 14

    How do I periodically reload a web page in a Terminal web browser?

  15. 15

    How do I use pushd and popd commands in Terminal?

  16. 16

    How do I resume an upgrade after pressing d for details in terminal?

  17. 17

    How do I permanently enable terminal output to a file?

  18. 18

    How do I install and use PyCharm without having to use a terminal?

  19. 19

    How do I install and use PyCharm without having to use a terminal?

  20. 20

    How do I respond to a terminal prompt before it is asked?

  21. 21

    How to pass a terminal command as an argument to another command

  22. 22

    How do I control window placement in KDE with keyboard?

  23. 23

    How do I launch a remote firefox window via SSH?

  24. 24

    How do I block the window.on('beforeUnload') event for <a> tag?

  25. 25

    In Xcode how do I get files to open in the same window

  26. 26

    how do I detect if window.location failed?

  27. 27

    How do I repair a broken Skype group chat (window)?

  28. 28

    How do I stop the animated movement of an object at the edge of the window?

  29. 29

    How do I force a tmux window to be a given size

뜨겁다태그

보관