If you have a process ID but aren't sure whether it's valid, you can use the most unlikely of candidates to test it: the kill command. If you don't see any reference to this on the kill(1) man page, check the info pages. The man/info page states that signal 0 is special and that the exit code from kill tells whether a signal could be sent to the specified process (or processes).
So kill -0 will not terminate the process, and the return status can be used to determine whether a process is running. For example:
$ echo $$ # show our process id 12833 $ /bin/bash # create new process $ echo $$ # show new process id 12902 $ kill -0 12902 $ echo $? # exists, exit code is 0 0 $ exit # return to previous shell $ kill -0 12902 bash: kill: (12902) - No such process $ echo $? # doesn't exist, exit code is 1 1
Many UNIX dæmons store their process IDs in a file in /var/run when they are started. Using kill -0 to test the pid is a lot easier than parsing ps output. For example, to test whether cron is running, do the following:
# kill -0 $(cat /var/run/cron.pid) # echo $? 0
txt2man converts flat ASCII text into the man page format. This allows you to author man pages without knowledge of nroff macros. It's a shell script that uses GNU awk, and it should run on any UNIX-like system. The script is available at mvertes.free.fr/txt2man/txt2man.
txt2man can generate its own man page for viewing on the screen via:
# txt2man -h 2>&1 | txt2man -T
The text source for the man page for txt2man is contained in the script itself; therefore, the source of the script shows you all you need to know to use txt2man.
If the program you want to install doesn't have a package for your distribution, you can use checkinstall to make one. Checkinstall makes Debian-, RPM- and Slackware-compatible packages. You can find checkinstall at asic-linux.com.mx/~izto/checkinstall.
Once you install it, download the source to the program you want to install and configure it and build it just as you normally would do. When it's time to run make install, use this instead:
Checkinstall will make a package and install it on your system. The original motivation for checkinstall was to create an easy way to remove programs that had been installed from source. Now that you have a package, you can remove it like any other package on your system.
Fast/Flexible Linux OS Recovery
On Demand Now
In this live one-hour webinar, learn how to enhance your existing backup strategies for complete disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible full-system recovery solution for UNIX and Linux systems.
Join Linux Journal's Shawn Powers and David Huffman, President/CEO, Storix, Inc.
Free to Linux Journal readers.Register Now!
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Profiles and RC Files
- Astronomy for KDE
- Understanding Ceph and Its Place in the Market
- Maru OS Brings Debian to Your Phone
- OpenSwitch Finds a New Home
- Git 2.9 Released
- SoftMaker FreeOffice
- What's Our Next Fight?
- The Giant Zero, Part 0.x
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide