Re: Question about nice

2004-11-16 Thread Dan Nelson
In the last episode (Nov 16), David J. Weller-Fahy said:
 I've set a very few commands as NOPASSWD in sudo, and run them from
 my normal user's crontab.  I've seen some examples of crontab's that
 use nice, but none that use sudo and nice.  That led me to a few
 questions. All paths have been stripped stripped - sudo and isoqlog
 are in
 /usr/local/bin, nice is in /usr/bin.
 
 1. I understand nice is useful if you need to run a program at a
 certain priority.  Is nice useful when not passing a priority?  If
 so, what is the difference between the following two commands (in
 terms of priority level)?
 
 nice isoqlog
 isoqlog

man nice: 

The nice utility runs utility at an altered scheduling priority, by
incrementing its `nice'' value by the specified increment, or a
default value of 10.
 
 2. If it is useful to run nice without passing a priority, then are
 the following two commands equivalent?  If not, which one would be
 preferred and why?
 
 nice sudo isoqlog
 sudo nice isoqlog
 
 I've been reading a bit, but haven't found a definite answer yet.  My
 feeling is that the answer to number one (first portion) is no, and
 thus the answer to number 2 (first portion) is no.  I'd be happy to be
 proven wrong, though. ;]

The first may take longer to execute on a busy machine, since sudo
itself is running at a lower priority.  The 2nd may be a security
hazard, depending on whether you allowed nice isoqlog or just nice
(with any command) in your sudo config file.

-- 
Dan Nelson
[EMAIL PROTECTED]
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Question about nice

2004-11-16 Thread David J. Weller-Fahy
* Dan Nelson [EMAIL PROTECTED] [2004-11-16 16:56 +0100]:
 In the last episode (Nov 16), David J. Weller-Fahy said:
  If so, what is the difference between the following two commands (in
  terms of priority level)?
  nice isoqlog
  isoqlog

 man nice:
 The nice utility runs utility at an altered scheduling priority,
 by incrementing its `nice'' value by the specified increment, or a
 default value of 10.

Doh!  I missed that in the man page.  Ok, I dug a little deeper and
found that the default priority is 0 (man setpriority, who would've
figured? :).  So, to answer my own question (with your prompting):
Prepending 'nice' to any command runs it at priority 10, without 'nice'
it would run at 0 (or 'normal').

Idle priorities range from 0 to 31, realtime from 0 to 31, and normal
priority is in between (and, according to setpriority, is also 0...
lots of zeros).

So it will make a difference.

  nice sudo isoqlog
  sudo nice isoqlog
 The first may take longer to execute on a busy machine, since sudo
 itself is running at a lower priority.  The 2nd may be a security
 hazard, depending on whether you allowed nice isoqlog or just nice
 (with any command) in your sudo config file.

I had decided not to allow 'nice' with any command, it's pleasant to see
that I was correct.  So using the first syntax for non-time-sensitive
programs would keep those from hogging the machines resources, correct?

Well, I think I've got it, now.  Thanks again for a pointer to the
obvious. ;]

Regards,
-- 
dave [ please don't CC me ]
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Question about nice

2004-11-16 Thread Svein Halvor Halvorsen

[David J. Weller-Fahy, 2004-11-16]
  1. I understand nice is useful if you need to run a program at a certain
  priority.  Is nice useful when not passing a priority?  If so, what is
  the difference between the following two commands (in terms of priority
  level)?
  
  nice isoqlog
  isoqlog

According to the man page nice(1)

 The nice utility runs utility at an altered scheduling priority, by
 incrementing its ``nice'' value by the specified increment, or a default
 value of 10.  The lower the nice value of a process, the higher its
 scheduling priority.

If you don't specify tge priority level, then mice adds 10.


  2. If it is useful to run nice without passing a priority, then are the
  following two commands equivalent?  If not, which one would be preferred
  and why?
  
  nice sudo isoqlog
  sudo nice isoqlog

The former will run sudo nice, which in turn will make isoqlog run as 
root, with the priority level inherited. The latter will make sudo run 
nice as root, and in turn run isoqlog with priority 10, with the effective 
user inherited.

The obvoius difference, is that you let sudo run nice without a password, 
you could do sudo nice anyprogram without a password.



   Cheers, 
   Svein Halvor
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Question about nice

2004-11-16 Thread David J. Weller-Fahy
* Svein Halvor Halvorsen [EMAIL PROTECTED] [2004-11-17 01:52 +0100]:
   nice isoqlog
   isoqlog
 According to the man page nice(1)
  The nice utility runs utility at an altered scheduling priority, by
  incrementing its ``nice'' value by the specified increment, or a default
  value of 10.  The lower the nice value of a process, the higher its
  scheduling priority.
 If you don't specify the priority level, then mice adds 10.

Ok, thanks Svein.

   nice sudo isoqlog
   sudo nice isoqlog

 The former will run sudo nice, which in turn will make isoqlog run as
 root, with the priority level inherited. The latter will make sudo run
 nice as root, and in turn run isoqlog with priority 10, with the effective
 user inherited.

 The obvoius difference, is that you let sudo run nice without a password,
 you could do sudo nice anyprogram without a password.

Yep, that's why I was concerned about it.  If there's no reason not to
run the first syntax, then that's what I'll use.

Regards,
-- 
dave [ please don't CC me ]
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]