LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 04-28-2007, 02:02 AM   #1
Patrick K
Member
 
Registered: Apr 2007
Distribution: Feisty (Ubuntu Studio)/Edgy
Posts: 69

Rep: Reputation: 16
Starting an app with increased priority.


I'm having a problem with Audacity. The sound breaks up on playback (didn't happen with Edgy).

I increased the priority using "nice -10". This got rid of the breakup. I'd like to start the program with a higher priority. I tried editing the launcher with "nice -10". "Sudo nice -10", "gksu nice -10", and "gksu nice -10". "Nice -10" set the priority at +10 not -10. Audacity wouldn't start with the others.

How can I raise the priority at its startup?

Using Feisty and ALSA with a M-Audio 2496 card. Audacity and Envy24 Control are usually the only apps running when recording or playing back.
 
Old 04-28-2007, 11:33 AM   #2
Mizzou_Engineer
LQ Newbie
 
Registered: Jan 2006
Location: Missouri
Distribution: Gentoo 2007.0 x86 & amd64
Posts: 25

Rep: Reputation: 15
Executing the command with "sudo nice -n -10 audacity" will do it. However, this runs the program as root, which you probably do not want. I'd look into the configuration of ALSA to ensure that it runs with as high of a priority as possible.
 
Old 04-28-2007, 12:19 PM   #3
Patrick K
Member
 
Registered: Apr 2007
Distribution: Feisty (Ubuntu Studio)/Edgy
Posts: 69

Original Poster
Rep: Reputation: 16
I'd rather not run as root but I already have to with jackd (not needed for Audacity but for Ardour and Hydrogen to use realtime access).

That executes Audacity with nice at -10 from the terminal. I'm not sure how to raise ALSA's priority. "Mixer_applet2" is the only process running. I guess that is ALSA. Guess I'll go to the ALSA site and see what I can find there. Thanks.
 
Old 04-28-2007, 02:11 PM   #4
Patrick K
Member
 
Registered: Apr 2007
Distribution: Feisty (Ubuntu Studio)/Edgy
Posts: 69

Original Poster
Rep: Reputation: 16
I found another way that might allow higher priority. "/etc/security/limits.conf" sets limits on groups. I can set my main group or the audio group at priority -10, however most all processes are set to this. Audacity doesn't breakup but the mouse is very jumpy. I don't know if there is another way to use this file to get just the audio processes to run at a higher priority without raising the priority of all processes. Thoughts?
 
Old 04-28-2007, 08:59 PM   #5
lazarith
LQ Newbie
 
Registered: Apr 2007
Posts: 7

Rep: Reputation: 0
I created an alias in my .bashrc file to do such things:
alias prioritize='~/scripts/prioritize.sh'

and in the script:
#!/bin/bash
sudo nice -$1 sudo -u <PutYourUserNameHere> $2

It could probably be done all in one line in .bashrc though.
It uses root privalage to set the priority to whatever you want and then runs the actual program with the more restrictive privalages. Just make sure that you have sudoers set up correctly.

Hope this way helps!
 
Old 04-29-2007, 02:50 AM   #6
Patrick K
Member
 
Registered: Apr 2007
Distribution: Feisty (Ubuntu Studio)/Edgy
Posts: 69

Original Poster
Rep: Reputation: 16
Thanks for replying. I'm afraid you have gotten over my head. I'm not sure how to write such a script. I tried editing sudoers (in another matter) but couldn't get it to save the edits. I used visudo to open the file but while it appeared to be saved, it wasn't. Could you perhaps provide more detail on both the script and how to edit (and save) sudoers?
 
Old 05-06-2007, 12:27 AM   #7
lazarith
LQ Newbie
 
Registered: Apr 2007
Posts: 7

Rep: Reputation: 0
>>Could you perhaps provide more detail on both the script and how to edit (and save) sudoers?
Did you run visudo with root privileges? (sudo visudo)?
Also, the default editor that visudo opens is dependent on how it was originally compiled. On my Feisty installation it opens in nano and saving is a matter of answering 'y' when prompted on exiting. If visudo opens vi you might try typing :wq on exiting? I don't know why else it might be discarding your changes.
Maybe use your favorite text editor (with root privileges) to open /etc/sudoers instead? Just be sure to only have one copy open at a time.

As for the script:
open ~/.bashrc in a text editor (it's a hidden file)
scroll down to the "# Alias definitions." section.
add alias prioritize='~/scripts/prioritize.sh'
now save, quit, and create a text file called prioritize.sh in a folder called scripts in your home directory.
Open it and add (with your username substituted for <PutYourUserNameHere>)
#!/bin/bash
sudo nice -$1 sudo -u <PutYourUserNameHere> $2

Save, quit.
reset your terminal/open a new one, and I believe it should work.
usage: sudo prioritize -5 "audacity"
This should run audacity with your normal privileges at priority -5.

Hope I was clearer this time :-)
 
Old 05-07-2007, 11:19 PM   #8
Patrick K
Member
 
Registered: Apr 2007
Distribution: Feisty (Ubuntu Studio)/Edgy
Posts: 69

Original Poster
Rep: Reputation: 16
Thanks for the reply. Sorry about not getting back sooner.

I tried the code you gave but get the message:
Quote:
sudo: prioritize: command not found
The directory with prioritize.sh is in the path. I tried both setting it as executable and not executable. It seems the alias in .bashrc isn't happening as expected.

Here is the line I used:
Quote:
alias prioritize='/home/pk/bin/prioritize.sh'
I went with a directory that I created a while back "~bin" but I don't see that as the problem.

I really have no idea what I've done wrong.
 
Old 05-08-2007, 11:23 PM   #9
lazarith
LQ Newbie
 
Registered: Apr 2007
Posts: 7

Rep: Reputation: 0
Hmm... Thats odd...
A couple things to try:

Quote:
sudo sh /home/pk/bin/prioritize.sh -5 "audacity"
Just to be sure that it works.

If it does then try typing
Quote:
alias prioritize='/home/pk/bin/prioritize.sh'
directly into the console. If prioritize works after that, then there's probably something wrong with where you added the prioritize line into .bashrc . Make sure that its not between a "if" line and a "fi" line.
 
Old 05-09-2007, 11:37 AM   #10
Patrick K
Member
 
Registered: Apr 2007
Distribution: Feisty (Ubuntu Studio)/Edgy
Posts: 69

Original Poster
Rep: Reputation: 16
The first line worked and started the app.

The second didn't. It just dumped me right back to the prompt. With sudo, I get "sudo: alias: command not found".

Here are the lines from .bashrc:
Quote:
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

# prioritize Audacity
alias prioritize='/home/pk/bin/prioritize.sh'

#if [ -f ~/.bash_aliases ]; then
# . ~/.bash_aliases
#fi

# enable color support of ls and also add handy aliases
if [ "$TERM" != "dumb" ]; then
eval "`dircolors -b`"
alias ls='ls --color=auto'
#alias dir='ls --color=auto --format=vertical'
#alias vdir='ls --color=auto --format=long'
fi

# some more ls aliases
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'
Just trying something:
After running the alias prioritize='/home/pk/bin/prioritize.sh' command, if I then type "prioritize" I get this
Quote:
pk@pk-desktop:~$ prioritize
Password:
nice: -: No such file or directory
 
Old 05-10-2007, 01:06 AM   #11
lazarith
LQ Newbie
 
Registered: Apr 2007
Posts: 7

Rep: Reputation: 0
It looks like you're missing "nice," which generally comes with Linux. If typing nice into the command prompt produces that error, then maybe you need the nice package. I'd try:
Code:
sudo apt-get install util-linux util-linux-locales
 
Old 05-10-2007, 10:13 PM   #12
Patrick K
Member
 
Registered: Apr 2007
Distribution: Feisty (Ubuntu Studio)/Edgy
Posts: 69

Original Poster
Rep: Reputation: 16
Looks like I have both packages you mentioned.
Quote:
util-linux is already the newest version.
util-linux-locales is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Maybe the argument is phrased incorrectly. It looks like the "-" may be what the error is about.
 
Old 05-11-2007, 11:02 AM   #13
lazarith
LQ Newbie
 
Registered: Apr 2007
Posts: 7

Rep: Reputation: 0
So, what happens when you run
Code:
prioritize -5 "audacity"
I guess it probably shouldn't work without those arguments anyway.
 
Old 05-11-2007, 04:41 PM   #14
Patrick K
Member
 
Registered: Apr 2007
Distribution: Feisty (Ubuntu Studio)/Edgy
Posts: 69

Original Poster
Rep: Reputation: 16
That works but sadly running Audacity with increased priority doesn't seem to have eliminated all the problems I'm having. I started another thread about returning to Edgy. I didn't have these problem with Edgy.

Thanks for all your help. It was great of you to take the time to make such a valiant effort. I really appreciate it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
process priority,nice -- small question regarding high/low priority values beeblequix Linux - Newbie 1 10-11-2006 11:22 AM
app that overrides IE from starting mimithebrain General 16 05-30-2006 01:42 AM
starting program with preset priority DropSig Linux - General 1 12-08-2005 12:37 AM
Starting An App From A Command-line linuxdawg Linux - Newbie 5 02-02-2005 10:06 AM
Starting a KDE app minimised? SMurf7 Linux - Newbie 3 03-08-2004 08:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 06:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration