LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-07-2005, 12:48 AM   #1
bjdea1
Member
 
Registered: Oct 2003
Posts: 37

Rep: Reputation: 15
Question about Kill command


I am trying to control the load on my servers. Currently I'm using a cron to run a script that reads in the output from a "top" command. If the load is above a certain predefined limit then it kills off processes that have been defined as expendable - in a config file.

The problem is backups run every week. If I exclude backups from the process killing script then the server load gets too high during the backup period and clients complain. If I include the backups in the process kill list then obviously backups don't all get done. Here's what I'd REALLY REALLY like to do instead. I'd like to use the "kill -STOP pid" command to pause the backup once the load goes over the limit. Then once it goes back under th elimit I'd like to restart the backup process with "kill -CONT pid". The problem is the backup process uses tar and gzip and I am unsure how the "STOP" affects these child processes. I mean if I stopped the backup parent process - what happens to th echlid processes tar and gzip? Do they die and never finish? Does this result in a half completed backup file? I've played around with it and it appears that when you restart the backup script with "CONT" the gzip and tar processes do not restart (continue) with it, instead the running backup process seems to assume they finished already and jumps to next step in backups.

Can anyone tell me how can I solve this - any ideas? Any help from anyone? Can anyone tell me how the "kill -STOP pid" handles child process of the stopped parent process. Could I use a pstree command to determine the relationship between processes and run the "kill - STOP pid" command on the children first and then the parent process and then when restarting - restart the children processes first and then the parent????? Help please anyone
 
Old 11-07-2005, 07:39 AM   #2
cardy
Member
 
Registered: Jan 2005
Location: Shropshire, England, UK
Distribution: RedHat, Fedora, CentOS..........
Posts: 121

Rep: Reputation: 19
Killing the processes seems harsh to say the least, are you aware of nice ?

Nice allows you to set a value for each process (by default 0) The nice value for a process will affect how it is scheduled. The lower the priority number the the less nice it will be e.g.

-20 is the higest priority

0 is the normal priority

19 is the lowest priority

[CODE]
nice -n 5 startbackup.sh
[CODE]

The above command would make the backup run with a lower priority than other commands on the system you could set the backup to run with a priority of 5, this means it will allow other processes first which should stop the clients complaining. In addition you could change your script to change the nice priority for other processes rather than killing them by using the command renice which allows you to change the priority of a process which is already running. Setting these processes to a nice value of 10 would mean the users processes get highest priority followed by the backups then the processes which you consider expendable.

If you use the program top the Nice value for a process is shown in the column NI.
 
Old 11-07-2005, 10:28 AM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,599
Blog Entries: 4

Rep: Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905
I agree... murder is effective, but much too draconian...

Remember, it is a good thing for the "system load" to be as high as it can possibly be! (The CPU loves to be busy.) That is, as long as there is not excessive waiting. If a queue is building up, then the bottleneck needs to be isolated and found.

If "load is too high," then it necessarily means that there is a bottleneck somewhere. It probably is not the CPU; it's probably some overloaded device, or the I/O channels that get you there.

The normal reason for the mantra, "add more RAM," is that this is a cheap-and-easy way to achieve more "I/O avoidance" without going to the trouble of hunting down where the root cause of the problem is. But sooner or later you have to do things like that anyway.

First question: are users actually complaining? If not, "no problem." But if they do, what exactly are they complaining about? A particular application? A particular file? Sluggish response-time? Okay then, who are they? What are they doing? Do other users complain similarly? Do you find little voodoo dolls of yourself with pins stuck through them in all the department cubicles, or just certain ones? All of these are clues.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Kill command could not kill Kanaflloric Linux - General 11 08-22-2005 07:18 AM
kill command question chunlee Linux - Newbie 5 10-18-2004 12:45 PM
The kill command tearinox Linux - Newbie 2 08-15-2003 04:40 PM
Kill a process by command ITJedi Programming 3 03-07-2003 10:49 AM
kill command... Sonny Linux - Newbie 2 01-28-2002 03:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:11 AM.

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