maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   OS2008 / Maemo 4 / Chinook - Diablo (https://talk.maemo.org/forumdisplay.php?f=29)
-   -   script for automatic renice command (https://talk.maemo.org/showthread.php?t=36870)

sangean99 2009-12-12 14:00

script for automatic renice command
 
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

JosefA 2009-12-12 14:06

Re: script for automatic renice command
 
Quote:

Originally Posted by sangean99 (Post 424367)
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.

sangean99 2009-12-14 08:59

Re: script for automatic renice command
 
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.

ruskie 2009-12-14 09:02

Re: script for automatic renice command
 
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

sangean99 2009-12-14 16:13

Re: script for automatic renice command
 
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.

ruskie 2009-12-15 09:40

Re: script for automatic renice command
 
Use:
Code:

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

sangean99 2009-12-16 19:58

Re: script for automatic renice command
 
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.

kwotski 2009-12-16 20:01

Re: script for automatic renice command
 
Quote:

Originally Posted by sangean99 (Post 430909)
I dont know the path of renice.
whereis command does not work. How to find out?

You want this:

Quote:

# which renice
/usr/bin/renice


sangean99 2009-12-18 17:36

Re: script for automatic renice command
 
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.


All times are GMT. The time now is 02:13.

vBulletin® Version 3.8.8