Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    script for automatic renice command

    Reply
    sangean99 | # 1 | 2009-12-12, 14:00 | Report

    Hi!

    I have N810. How can I write a short script to do the following?
    Get the pid of a process like:

    ps | grep <your_app_name> | cut -b 1-5 | head -1

    and then use that pid number in the 'renice' command to put the priority higher like:

    renice -20 -p 1735

    Edit | Forward | Quote | Quick Reply | Thanks

     
    JosefA | # 2 | 2009-12-12, 14:06 | Report

    Originally Posted by sangean99 View Post
    Hi!

    I have N810. How can I write a short script to do the following?
    Get the pid of a process like:

    ps | grep <your_app_name> | cut -b 1-5 | head -1

    and then use that pid number in the 'renice' command to put the priority higher like:

    renice -20 -p 1735
    Code:
    renice -20 $(pidof appname)
    Ought to do it, I think.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    sangean99 | # 3 | 2009-12-14, 08:59 | Report

    Hi thanks!

    Can you write down the whole code that I should put into a script file?

    I guess first the script should find out the pid# and then in the next line use that pid# with the renice command.

    I could execute that automatically.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    ruskie | # 4 | 2009-12-14, 09:02 | Report

    The above is the whole code.

    Code:
    #!/bin/sh
    renice -20 $(pidof $1)
    Name it whatever you want.sh chmod +x it then run it with:

    ./wahtever you want.sh appname

    Edit | Forward | Quote | Quick Reply | Thanks

     
    sangean99 | # 5 | 2009-12-14, 16:13 | Report

    ok, but renice command needs root. if i put root into script then it enters root but it continues the script only when i type exit from root.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    ruskie | # 6 | 2009-12-15, 09:40 | Report

    Use:
    Code:
    sudo renice -20 $(pidof $1)
    Instead of plain renice and edit your /etc/sudoers file to allow running renice without a password.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    sangean99 | # 7 | 2009-12-16, 19:58 | Report

    Ok, I have found directory: /etc/sudoers.d
    It has 7 files. I made a copy but I dont know the path of renice.
    whereis command does not work. How to find out?
    and where is the ping command located? That needs root also.
    I also tried to search with Midnight Commander for ping file but it didnt find it.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    kwotski | # 8 | 2009-12-16, 20:01 | Report

    Originally Posted by sangean99 View Post
    I dont know the path of renice.
    whereis command does not work. How to find out?
    You want this:

    Originally Posted by
    # which renice
    /usr/bin/renice

    Edit | Forward | Quote | Quick Reply | Thanks

     
    sangean99 | # 9 | 2009-12-18, 17:36 | Report

    Well, I have the following files in /etc/sudoers.d directory:

    01sudo
    flash-and-reboot.sudoers
    hildon-application-manager.sudoers
    hildon-input-meth~igurator.sudoers
    osso-af-startup.sudoers
    osso-app-killer.sudoers
    ukeyboard.sudoers

    The first one has the most lines.

    So to which one should I include the following line?

    user ALL = NOPASSWD: /usr/bin/renice

    I put it into the first file but it still doesn work without root.

    Edit | Forward | Quote | Quick Reply | Thanks

     
vBulletin® Version 3.8.8
Normal Logout