Jump to content

Set the priority of a process higher permanently


BusDriver

Recommended Posts

On my Orange Pi Zero I run Armbian Buster and the only software running is Shairport. Unfortunately I used to have a crackling noise every 20-40 secund which was solved after entering 


root@orangepizero:~# renice -n -19 -u shairport-sync
110 (user ID) old priority 0, new priority -19
 

So far so good - but after a reboot the prio is again 0. 

 

So I tried to use nice 

nice -19 shairport-sync
 

but after a reboot the prio was again 0

 

How can I set the priority of all process run by the user (-u) “shairport-sync” to -19 when they start?

Link to comment
Share on other sites

Many thanks for pointing me to the init.d file. I did read the pages I could find on how to enter commands to it, I tried several ways but still the priority is low. 

 

What I tried:


START_ARGS="--chuid ${USER}" "nice -n -19 shairport-sync"
 

and 


START_ARGS="--chuid ${USER}" "renice -n -19 -u shairport-sync"

 

But still the priority is 0 after reboot :(

Link to comment
Share on other sites

Doesn't Debian use systemd for their stuff? The init.d files might be there only for legacy reasons. You probably have to edit the corresponding systemd file. Check if you find it in /lib/systemd/system

Link to comment
Share on other sites

Thanks for pointing me here, this triggered some research- in /lib/systemd/system I do find the shairport-sync.service file. There I entered the ExecStartPost command

 

[Unit]
Description=Shairport Sync - AirPlay Audio Receiver
After=sound.target
Requires=avahi-daemon.service
After=avahi-daemon.service
Wants=network-online.target
After=network.target network-online.target

[Service]
ExecStart=/usr/local/bin/shairport-sync
User=shairport-sync
Group=shairport-sync
ExecStartPost=renice -n -19 -u shairport-sync

[Install]
WantedBy=multi-user.target
 

But the only effect this had was killing the service completely :( seems like my syntax is wrong. 

 

In https://www.freedesktop.org/software/systemd/man/systemd.exec.html# I found the info that I can use "Nice" - how nice! So the new config is

 

[Unit]
Description=Shairport Sync - AirPlay Audio Receiver
After=sound.target
Requires=avahi-daemon.service
After=avahi-daemon.service
Wants=network-online.target
After=network.target network-online.target

[Service]
ExecStart=/usr/local/bin/shairport-sync
User=shairport-sync
Group=shairport-sync
Nice=-19

[Install]
WantedBy=multi-user.target
 

And yeah, this works! Many many thanks!

 

So to wrap up the issue and the solution: 

Shairport-Service used to have cracks and noise which disappeared by

entering renice -n -19 -u shairport-sync

after start. However, after Reboot, this was lost. So the solution was to go to /lib/systemd/system , edit the existing shairport-sync.service file by adding 

Nice=-19

to the config. Check if this works by rebooting and doing "top".

Link to comment
Share on other sites

Try nice instead of renice. renice is used to adjust the nice-level of already existing processes. nice is used to give a newly created proces a specific priority.

Link to comment
Share on other sites

Correct, in the successful config I have used nice. 

 

The reason why I tried renice in the first try was, that I expected the service to be running already. It would have been more like a hack to "command-line" renice after start. setting it properly in the service config is the better way. 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines