On most medium to large scale companies, most demanding production servers I know undergo a few minutes of executing batches of scheduled shell scripts or linux commands. These shell scripts and linux commands consume a lot of time and server work load before finishing certain particular job specially for CPU-cycle-eating scripts and linux commands. Thus lessening server performance and response time to normal daily operations of a non-load-balanced production servers.
How to stop, pause, and continue a currently running process job?
How to create a pending linux shell process?
How to temporarily stop a command?
Here's how to achieve the effect of pausing a linux process.
This blog entry would assume, as an example, running a CPU-cycle-eating linux command, then temporarily pause and stop it, and later on continue executing th process without killing the actual PIDs.
Let's start.
Run updatedb into the background forking a process
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# updatedb &
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Determine current process PIDs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ps axuw | grep updatedb | grep -v grep
root 3264 5.2 0.0 3852 800 pts/0 D 12:35 0:00 updatedb
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Noticed from the above lines that the executed updatedb represent a PID of 3264 . Take note of this as we are going to need this when pausing the process.
Next, confirm that the updatedb linux command is still being processing and running
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# jobs
[1]+ Running updatedb &
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Now, let's pause the linux process
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# kill -STOP 3264
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Reconfirm if the process is still running
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# jobs
[1]+ Stopped updatedb
# ps axuw | grep update
root 3264 1.4 0.0 3852 800 pts/0 T 12:35 0:00 updatedb
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From the issued commands above, we have successfully paused a currently running process. The updatedb process with PID 3264 is now a currently frozen process. Eventually, depending on CPU cycles and disk activity needed by your scheduled batch of shell scripts and linux commands, server work load would gradually decreased then and much more response time would be available for others to use.
As a sample of stopping ,pausing and continuing a linux process, we can now continue executing the currently stopped linux process:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# kill -CONT 3264
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Verify that the process is now running
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# jobs
[1]+ Running updatedb &
# ps axuw | grep updatedb
root 3272 0.0 0.0 4044 672 pts/0 S+ 12:37 0:00 grep update
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The line below shows that the background process of updatedb was already finished with its job.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[1]+ Done updatedb
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As you can see, the updatedb process was stopped, pause and continued using the 'kill' command.
You might be interested with the shown advertisement from those black boxes around.
HTH
Here is kill description from man page:
The command kill sends the specified signal to the specified process or process group. If no signal is specified, the TERM signal is sent. The TERM signal will kill processes which do not catch this signal. For other processes, it may be necessary to use the KILL (9) signal, since this signal cannot be caught.
Subscription
Categories
- HowTos (612)
- Linux Devices (40)
- Linux Diggs (620)
- Linux News (1541)
- Linux Videos (24)
Recent Posts
Blog Archive
-
▼
2007
(340)
-
▼
November
(39)
- HowTo: Strip directory path and filename suffix
- HowTo: Get the Filename Extension Only
- Tailf - watch the linux log file grows
- Fedora 8 with Enlightenment Window Manager
- HowTo: ScreenCasts & Desktop Records via Istanbul
- HowTo: Record Desktop Session via Byzanz
- Linux Scorched 3D Tank Game
- Linux Atomic Battle Tank Game
- HowTo: Display a Tree of Linux Processes
- Howto: 3 Easy Install Steps of Microsoft Fonts in ...
- Howto: Convert PDF to HTML/XML/PNG in Linux
- Livna Repository on Fedora 8
- Linux Action Flight Simulator Game
- Splitting and Merging Multiple Linux Files
- Sort Nth Position of Nth Column of a File in Linux
- Stop, Pause, and Continue A Linux Process
- File Creation without File Opening in Linux
- Concatenate Multiple Files in Linux
- Renaming Files in Linux
- Linux Power Consumption Analysis Tool
- Tail and Head Few Lines of Text Files
- Three Easy Steps for Opera on Fedora 8
- Alternative Search and Replace Tool
- Display Lines Beginning with a Given String
- Spell Check Files via Terminal - Install Howto
- Display Linux Session Jobs
- Get Linux Disk Space and Usage
- Change Linux RunLevels Howto
- Audacious - Install Howto
- Amarok - Howto Install
- Sun Java on Fedora 8 Install HowTo
- My Fedora 8 Diary
- Chikka on Kopete Messenger Howto
- Linux Files and Folders Local Copying
- Linux folders and directories recursive removal
- MailX - Mail Facility via Terminal
- Time zone values interpretation
- Retrieving Linux Standard Base and Distro Information
- Fedora Firstboot
-
▼
November
(39)
Thursday, November 22, 2007
Stop, Pause, and Continue A Linux Process
Subscribe to:
Post Comments (Atom)
ILoveTux - howtos and news | About | Contact | TOS | Policy
0 comments:
Post a Comment