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.
Categories
- HowTos (611)
- Linux Devices (39)
- Linux Diggs (620)
- Linux News (1541)
- Linux Videos (24)
Recent Posts
Blog Archive
-
►
2008
(2302)
-
►
October
(140)
- Linus Torvalds on Linux Distributions
- AMD to Spin off Manufacturing Operations
- MySQL cofounder David Axmark leaving Sun
- Mono to contribute back to CLI; Microsoft says it ...
- Monitor your network with GroundWork Monitor Commu...
- The LXF Guide: Write a Perl module
- 8 Best First-person Shooter Games for Linux
- AppDeploy Community Launches Free Windows Installe...
- Ubuntu Tweak - Sneak Peak at Latest Version!
- POS stack targets Linux netbooks
- RIP LinuxWorld
- Firefox extension blocks dangerous Web attack
- Wikia co-founder to speak at linux.conf.au
- Wikia co-founder to speak at linux.conf.au
- Look Ma, No ‘X’
- Look Ma, No ‘X’
- Forget the damn Linux netbooks. Can Windows replac...
- Forget the damn Linux netbooks. Can Windows replac...
- Amarok 2.0 Beta 2 was released
- 6 Years As A Professional Software Developer
- Amarok 2.0 Beta 2 was released
- 6 Years As A Professional Software Developer
- Distribution Release: EnGarde Secure Linux 3.0.21
- Torvalds talks about his brand new blog
- Become a multimedia pro with the Vector Linux Mult...
- Linux Robot - Watch This Space
- Distribution Release: EnGarde Secure Linux 3.0.21
- Torvalds talks about his brand new blog
- Become a multimedia pro with the Vector Linux Mult...
- Linux Robot - Watch This Space
- Linux-Based E-Voting In Brazil
- Is .NET on Linux Finally Ready?
- Linux-Based E-Voting In Brazil
- Multi-core networking stack ported to PowerPC
- Google rev's photo editor for Linux
- Project releases version 2.0 of open source .Net
- One more 2.6.27 prepatch
- Stallman vs. Clouds
- How to Create and Use a Password Reset Disk in Win...
- OpenOffice.org Grows Up
- 45+ Sources and Sets of Photoshop Custom Shapes
- Clean up your filesystems with fslint
- NPX-9000 UMPC is inexpensive but underpowered
- Will Chrome Find a Home With SaaS?
-
►
October
(140)
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