linux(SUSE) service 自啟動服務
1.what is rc_status
The commands from rc.status are actually SuSe specific I think. AFAICT they handle two things: output to the user and the final return status of the script. rc_status
checks
if the previous command (i.e. the start/restart/stop of a service)executed successfully and sets the "status value"
rc_exit
(which
you place at the end of your init.d script). Source
You can conceivably write your shell script without them, but I assume they help making sure that your script conforms to LSB requirements and blends in well with other system scripts. I bet most of this is actually documented in the
/etc/rc.status
file,
though. I just don't have a suse box handy.
2.what is checkproc
NAME
Checkproc - Checks for a process by full path namePidofproc - Checks for a process by exec base name
SYNOPSIS
checkproc [-v] [-L] [-k] [-N] [-ppid_file] [-iingnore_file] [-croot] [-z] /full/path/to/executablecheckproc [-v] [-k] [-n] name_of_kernel_thread
pidofproc [-k] basename_of_executable
REQUIRED
- /full/path/to/executable or name_of_kernel_thread
- Specifies the executable which processes should be found, or alternatively, if the option Or alternated, if option -n is used, the name of the kernel thread. This argument is always required.
EXAMPLE
- checkproc /usr/sbin/sendmail
- returns all pids of running sendmail processes.
- checkproc -p /var/myrun/lpd.pid /usr/sbin/lpd
- returns the command line or the basename of the process pid found in /var/run/lpd.pid.
EXIT CODES
The exit codes without the option -k have the following LSB conform conditions:-
- 0
- Program is running
- 1
- No process but pid file found
- 3
- No process and no pid file found
-
- 101
- Wrong syntax on command line
- 102
- Other errors
If the option -k is used checkproc uses exit codes like (8) or (8) do:
-
- 0
- Program is running
- 1
- Generic or unspecified error
- 2
- Invalid or excess argument(s)
- 4
- Insufficient privilege(s)
- 5
- Program is not installed
- 7
- Program is not running
in some cases a message is send to standard error or, if no standard error available, (8) is used.