Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: Permanently set the NICE value of a program?

  1. #1
    Join Date
    Oct 2011
    Beans
    18

    Exclamation Permanently set the NICE value of a program?

    Hello, I run a Garry's Mod server using SRCDS for linux. I have very recently created this server, and today I got complaints of a lot of lag, and it crashing too much. I tried to solve this by Exiting all of the programs I don't use while the server is running, and I also tried setting the NICE value to -20 in terminal. At first this worked, but now whenever the server restarts, the NICE value returns to normal. Because of it being the type of server it is, it will restart maybe once every hour.

    I cannot constantly be tending the program, so that is where my question comes in. How can I make an application automatically set it's NICE value when started?

    Thank you, and I hope this forum will help me in my exploration into the world of Ubuntu!

  2. #2
    Join Date
    Oct 2011
    Beans
    18

    Re: Permanently set the NICE value of a program?

    Are bumps against the rules in this server?

    Bump

  3. #3
    Join Date
    Jan 2008
    Location
    Manchester UK
    Beans
    13,573
    Distro
    Ubuntu

    Re: Permanently set the NICE value of a program?

    Quote Originally Posted by Huntereb View Post
    Are bumps against the rules in this server?

    Bump
    No, but 24hours is the recommended time.

    Maybe a move to the Server Platforms section will help.

    The thread will still be visible in General Help with a redirect here visible for 3 days.

  4. #4
    WasMeHere is offline Iced Almond Soy Ubuntu, No Foam
    Join Date
    May 2008
    Location
    Sverige
    Beans
    1,133

    Re: Permanently set the NICE value of a program?

    Welcome to the Ubuntu Forums, Huntereb

    I think that you can start the programs that should have high priority with negative niceness as you suggested (with superuser privileges). This applies to autostarted programs too. You can also start the other programs with increased niceness (maximum 19) or simply avoid using your computer for other things while it is a server.

    Read the info page about nice
    Code:
    info nice
    Did you consider installing Ubuntu Server, that runs without desktop graphics leaving more power for the real server tasks?

    Have fun finding out about Ubuntu
    Olle

  5. #5
    prodigy_ is offline May the Ubuntu Be With You!
    Join Date
    Mar 2008
    Beans
    1,219

    Re: Permanently set the NICE value of a program?

    Quote Originally Posted by Huntereb View Post
    Because of it being the type of server it is, it will restart maybe once every hour.
    I'm not very familiar with SRCDS, but renice is probably what you want. If you need help with scripting, I'll need to know how exactly the server is restarted but the basic idea is:


    Code:
    # Some command, the server is restarted.
    ...
    # Get the (new) SRCDS PID, grep args depend on the output of ps.
    PID=$(ps -ef | grep ... )   
    # Change niceness.
    renice -20 $PID
    Last edited by prodigy_; October 25th, 2011 at 03:45 PM.

  6. #6
    Join Date
    Oct 2011
    Beans
    18

    Re: Permanently set the NICE value of a program?

    Quote Originally Posted by prodigy_ View Post
    I'm not very familiar with SRCDS, but renice is probably what you want. If you need help with scripting, I'll need to know how exactly the server is restarted but the basic idea is:


    Code:
    # Some command, the server is restarted.
    ...
    # Get the (new) SRCDS PID, grep args depend on the output of ps.
    PID=$(ps -ef | grep ... )   
    # Change niceness.
    renice -20 $PID
    So how would I go about making this work? Do I use another terminal along side the server terminal?

    From my understanding, I need a code that will scan the application every minute or less (the program has a specific name, srcds_linux). And when it detects a new PID it will set the NICE back to -20 automatically. But there's one problem with that, to set the NICE value to -20 you need to type the sudo password. So is it possible to make it so you only have to type the password once and it will work every time from there until you exit the terminal?

    I would need a lot of help with this, I don't know where to start with this, but what I said above would solve my problem completely.

    Also, no I don't want to get rid of the Ubuntu GUI and go to having the computer run as a terminal only. Is there a way maybe to run Ubuntu in a lower graphics mode as well? Like Windows Recovery Mode.

  7. #7
    WasMeHere is offline Iced Almond Soy Ubuntu, No Foam
    Join Date
    May 2008
    Location
    Sverige
    Beans
    1,133

    Re: Permanently set the NICE value of a program?

    Code:
    sudo -s
    makes the terminal window keep the current user as root. It is not generally recommended, because you can easily damage your system, but in your case maybe it would be a solution.

    Another solution might be to use cron. It is a little tricky because the environment is very limited.

  8. #8
    Join Date
    Oct 2011
    Beans
    18

    Re: Permanently set the NICE value of a program?

    So could someone please combine all of the commands I need here so it will work? I understand everything you guys are throwing at me, I'm just not sure which codes I need to use all togethor to do this. Like, which one goes first, second, and so on.

  9. #9
    WasMeHere is offline Iced Almond Soy Ubuntu, No Foam
    Join Date
    May 2008
    Location
    Sverige
    Beans
    1,133

    Re: Permanently set the NICE value of a program?

    Quote Originally Posted by Huntereb View Post
    ...
    Also, no I don't want to get rid of the Ubuntu GUI and go to having the computer run as a terminal only. Is there a way maybe to run Ubuntu in a lower graphics mode as well? Like Windows Recovery Mode.
    It might be attractive for you to run Ubuntu with a small foot-print desktop environment (compared to 'vanilla' Ubuntu or Kubuntu). Try Xubuntu with XFCE or Lubuntu with LXDE. This way your desktop graphics will use less RAM and the computer will be faster. In other words, there will be more power for your server task.

  10. #10
    Join Date
    Oct 2011
    Beans
    18

    Re: Permanently set the NICE value of a program?

    Quote Originally Posted by Olle Wiklund View Post
    It might be attractive for you to run Ubuntu with a small foot-print desktop environment (compared to 'vanilla' Ubuntu or Kubuntu). Try Xubuntu with XFCE or Lubuntu with LXDE. This way your desktop graphics will use less RAM and the computer will be faster. In other words, there will be more power for your server task.
    But if I installed Xubuntu (By the way, it looks great. Thanks!), would I have to remove all of the files from my computer and start all over again? I mean I can, I'll just copy everything I need for the server to my Dropbox, but is it possible to just update inside the Ubuntu I have now so it keeps all of my old files, but installs the new OS? I'm guessing not, but it would be a lot easier.

    Also, I still need help with my last post.

Page 1 of 3 123 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •