Understanding Red Hat Run Levels
Do you want to not start the HTTP daemon, without removing the file from the rc3.d directory? Easy. Rename /etc/rc.d/rc3.d/S85httpd to something that does not start with a capital S or a capital K. Your best bet would be to rename files using a lowercase “s” or a lowercase “k”. This way, not only will the scripts not be started, but they'll appear later in an ls file listing, since entries starting with capital letters are shown separately from those beginning with lower case letters. So you'd wind up with a file now called s85httpd, which is somewhat separated from the rest of the entries an an ls -l listing.
An important note here, though: make sure you know what the scripts are doing when you disable them. If you disable something like the S10network script, none of your networking software will work. This is why S10network has such a low number: because other scripts are dependent on the network and must be executed after the network software is in place.
You want to make your own init processes to start and stop? That's easy enough to do. Make a script that accepts the word start as an option. Not all scripts need to be able to stop, but if the script starts a process in the background, you should almost certainly include a stop option as well. For example, a script that polls the time over the network every time you enter runlevel 3 does not need a stop. A script that starts a program to query the network time every 15 minutes would need a start and a stop script, since the program the script started is continuously running. A program for the second example is better suited from a crontab, but being able to do things your own way is at the heart of Unix, isn't it?
Once it's written (and tested), put it in the /etc/rc.d/init.d/ directory. Let's say it's the program to check the time on a network machine every 15 minutes, so we'll call the script “netdate”. Once it is in the /etc/rc.d/init.d/ directory, you can make links in the directories you want to start it in. If you want your program to run in runlevel 3, make a link to your script from /etc/rc.d/rc3.d/S??netdate. Make ?? a number that will fit in the rest of the directory, such as S55netdate. You'll want it to be above S10 so that the network is started, and S55 isn't taken, so it seems a good enough location. It's not required that there be only one script with each number, but it is good form, since you know exactly what order the scripts will be started in.
If you want to stop the process gracefully during a shutdown, make sure your script accepts stop, then make a link to /etc/rc.d/init.d/netdate from /etc/rc.d/rc0.d/K55netdate. Again, you should make sure the number you use is not being used by another subsystem to avoid confusion.
You can test your new setup by using init 3. Since the other subsystems are already running, the only one that will start is the one you just added. If the init 3 command hangs, your script didn't exit; you probably need to put an ampersand at the end of a line to put the problem process in the background. You can also run your script manually from the /etc/rc.d/init.d/ directory.
Now that you know how the subsystems work, you can easily add or modify the existing subsystems for your particular Linux setup.
Mark Komarinski (email@example.com) has been using Linux since 1993 when he first purchased his 386/40. He just completed a book on Linux to be published by Prentice Hall. Mark now works for Aurora Technologies doing internal PC support and manning the customer service phones. He lives in eastern MA with his wife, Brenda.
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!
- Google's Abacus Project: It's All about Trust
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Seeing Red and Getting Sleep
- Secure Desktops with Qubes: Introduction
- Fancy Tricks for Changing Numeric Base
- Working with Command Arguments
- Secure Desktops with Qubes: Installation
- Back to Backups
- CentOS 6.8 Released
- Linux Mint 18
Until recently, IBM’s Power Platform was looked upon as being the system that hosted IBM’s flavor of UNIX and proprietary operating system called IBM i. These servers often are found in medium-size businesses running ERP, CRM and financials for on-premise customers. By enabling the Power platform to run the Linux OS, IBM now has positioned Power to be the platform of choice for those already running Linux that are facing scalability issues, especially customers looking at analytics, big data or cloud computing.
￼Running Linux on IBM’s Power hardware offers some obvious benefits, including improved processing speed and memory bandwidth, inherent security, and simpler deployment and management. But if you look beyond the impressive architecture, you’ll also find an open ecosystem that has given rise to a strong, innovative community, as well as an inventory of system and network management applications that really help leverage the benefits offered by running Linux on Power.Get the Guide