Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I prioritize Bash scripts in Linux, and do children of these scripts inherit the priority?

I have a script playing various movie clips on a computer using a video player. It's smooth. However, whenever a cron job is run where big files are to be downloaded, the video feed starts flickering. I believe this is due to the read/write needed to be done while downloading and playing at the same time.

My questions are:

  1. Can I prioritize a task in Linux?
  2. Can the prioritized task be a Bash script?

If so, will scripts and programs that run from that prioritized script inherit the priority?

like image 621
Paolo Avatar asked Dec 13 '25 13:12

Paolo


1 Answers

You can set a process' priority with the nice command when launching the process, or with the renice command on existing processes.

Any normal user processes can have a lower priority. Only root-owned processes can have a higher priority.

To launch a lower priority process, use a command like:

nice -10 mycommand.sh

In this case the priority is 10 - which is a less favourable priority than normal; the process will have a lower priority on the system than a command not started with nice.

Sub-processes inherit the same priority as their parent by default.

like image 58
Vorsprung Avatar answered Dec 16 '25 04:12

Vorsprung



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!