Http://blog.sina.com.cn/s/blog_57421ff80100c7nn.html1 Linux creates a self-starting Program
Both methods of self-starting are tested by yourself.
1.1 method 1 of self-starting program:
Add/home/Robin/code/autoruntest>/dev/null in etc/rc. Local (the autoruntest test program name, the same below ). You can start it yourself.
1.2 method 2 of self-starting program:
To create a Linux service, follow these steps:
1) write the Service Startup Script File (see the following example)
2) modify the CHMOD 777 autoruntest script file.
3) copy the script file to/etc/rc. d/init. d/
4) chkconfig -- add autoruntest to add a service
5) Restart (completed)
After step 3, you can start and stop using the service. To start the service, you must use chkconfig to add the service to the system.
2. Services in Linux
To customize system services, you must use the root user. Through the ntsysv command, you can see all the services of the system and whether they are started together with the system. Here, you can customize system services. The operation interface is shown in, here we can see that the test program autoruntest has been added as a system service and runs along with the system. Here you can customize the started service. Press F1 to see the introduction of each service. The system service description is attached.
3 appendix 3.1 example of a service script file
#! /Bin/bash
#
# Autoruntest the shell script takes care of autoruntest Auto Start and Stop
#
# Chkconfig: 2345 20 80
# Description: autoruntest
# Processname:/etc/rc. d/init. d/autoruntest
Exec_path =/home/Robin/code
Exec = autoruntest
Pid_file =/var/run/autoruntest. PID
Daemon =/home/Robin/code/autoruntest
# Source function library.
./Etc/rc. d/init. d/functions
If! [-X $ exec_path/$ exec]; then
Echo "error: $ exec_path/$ exec not found"
Exit 1
Fi
Stop ()
{
Echo "stoping $ exec ..."
Killall $ daemon>/dev/null
Usleep 100
Echo "shutting down $ Exec: [OK]"
}
Start ()
{
Echo "Starting $ exec ..."
$ Daemon>/dev/null &
Usleep 100
Echo "Starting $ Exec: [OK]"
}
Restart ()
{
Stop
Start
}
Case "$1" in
Start)
Start
;;
Stop)
Stop
;;
Restart)
Restart
;;
Status)
Status-p $ pid_file $ daemon
;;
*)
Echo "Usage: Service $ exec {START | stop | restart | status }"
Exit 1
Esac
Exit $?
3.2 System Service Introduction
1. alsasound: the Alsa audio card driver daemon.
2. acpid: acpid (Advanced Configuration and Power Interface) is a new power management standard to replace the traditional APM power management standard. Generally, the laptop needs to be powered on for management.
3. atalk: appletalk network daemon.
4. AMD: automatically installs the NFS daemon.
5. anacron: An automated task daemon.
6. apmd: apmd (Advanced Power Management) is advanced power management.
7. arptables_jf: Specifies the daemon for user control of the arptables network.
8. arpwatch: records logs and constructs an ethernet address and IP address pair database seen on the LAN interface.
9. autofs: automatically installs the management process automount, which is related to NFS and depends on the NIS server.
10. bootparamd: boot parameter server that provides information required for booting a diskless workstation on the LAN.
11. ch: the Bluetooth server daemon process.
12. crond: cron is a traditional UNIX program that periodically runs user-scheduled tasks. Compared with the traditional unix version, the Linux version adds many attributes, which are safer and easier to configure. Similar to scheduled tasks.
13. Chargen: the chargen server using the TCP protocol. Character Generator protocol is a network service. Its main function is to provide a function similar to remote typing.
14. Chargen-udp: Use the chargen server of UDP protocol.
15. cpuspeed: monitor the idle percentage of the system to reduce or speed up the CPU clock speed and voltage so as to minimize the energy consumption when the system is idle, while maximizing the system execution speed when the system is busy.
16. DHCPD: service daemon of the Dynamic Host Control Protocol.
17. CUPS: CUPS (Common Unix Printing System) is a universal Unix print daemon.
18. cups-config-daemons: the cups printing system switches the daemon process.
19. cups-LPD: the daemon for printing cups rows.
20. Daytime: the daytime daemon of TCP protocol is used to obtain the date and time from the remote server for the client. Default port: 13.
21. Daytime-udp: Use the daytime daemon of UDP protocol.
22. dc_server: the proxy server daemon that uses the SSL secure socket.
23. dc_client: the client daemon that uses the SSL secure socket.
24. diskdump: the server disk backup daemon.
25. Echo: the server displays the customer data service daemon.
26. Echo-udp: the server that uses the UDP protocol returns the client data service daemon.
27. eklogin: a service daemon that accepts rlogin session authentication and is encrypted with kerberos5.
28. gated: Gateway Routing daemon. It supports various routing protocols, including rip version 1 and 2, DCN Hello protocol, OSPF version 2, and EGP version 2 to 4.
29. GPM: the GPM (general purpose mouse Daemon) daemon provides mouse support for Linux programs in text mode, such as MC (midnight Commander.
30. gssftp: ftp daemon using Kerberos 5 Authentication
31. httpd: the Apache daemon of the Web server.
32. inetd: Internet operation daemon.
33. innd: Usenet news server daemon.
34. iiim: the daemon process of the Chinese Input Method server.
35. iptables: iptables firewall daemon.
36. IrDA: infrared port daemon.
37. ISDN: start and stop the service daemon process.
38. krb5-telnet: Telnet Daemon using Kerberos 5 authentication.
39. Klogin: log on to the daemon remotely.
40. keytable: the function of this process is to reprinted the keyboard ing table defined in/etc/sysconfig/keyboards. This table can be selected using the kbdconfig tool. You should make the program active.
41. irqbalance: the Server Load balancer daemon for system interrupt requests in multiple system processor environments. If you only install one CPU, you do not need to load this daemon.
42. kshell: kshell daemon.
43. Kudzu: hardware automatic detection program.
44. LDAP: LDAP (Lightweight Directory Access Protocol) Directory Access Protocol server daemon process.
45. lm_seroems: detects the working process of the motherboard.
46. lpd: lpd is an old-fashioned print daemon that submits LPR and other programs to print jobs.
47. mdmonitor: the daemon of RAID-related devices.
48. messagebus: The D-BUS is a library that provides one-to-one communication for two or more applications.
49. microcode_ctl: encodes and sends new microcodes to the kernel to update intel ia32 series Processors.
50. mysqld: a fast, efficient, and reliable lightweight SQL database engine daemon process.
51. Named: DNS (BIND) server daemon.
52. netplugd: The netplugd (network cable hotplug management Daemon) daemon is used to monitor the status of one or more network interfaces and run an external script program when some events are triggered.
53. netdump: Remote network backup server daemon.
54. netfs: network filesystem mounter. This process installs and uninstalls NFS, Samba, and NCP network file systems.
55. NFS: Network File System daemon.
56. nfslock: NFS is a popular protocol for sharing files through TCP/IP networks. This daemon provides the NFS file locking function.
57. ntpd: Network Time Protocol daemon (network time correction protocol ). Ntpd is a protocol daemon process used to synchronize time between the system and a precise time source.
58. Network: enable/disable the network interface daemon at startup.
59. psacct: the daemon includes several tools used to monitor process activity, including AC, lastcomm, accton, and SA.
60. pcmcia: it is mainly used to support the daemon process of the laptop interface.
61. Portmap: This daemon is used to support RPC connections. RPC is used for NFS, NIS, and other services.
62. PostgreSQL: PostgreSQL relational database engine.
63. ProFTPD: ProFTPD is a dedicated FTP server daemon in UNIX.
64. pppoe: ADSL connection daemon.
65. Random: a high-quality random number generator for saving and restoring the system. These random numbers are provided by Uniform Random behaviors.
66. rawdevices: used to load the daemon of raw devices when using the cluster file system.
67. readahead, readahead_early: readahead and readahead_early are two backend daemon programs launched in Fedora Core 2. The function is to read the files used to start the system to the memory during system startup, and then execute the files in the memory to speed up the system startup.
68. rhnsd: Red Hat Network Service daemon. Notify the official security information and patch the system.
69. Routed: This daemon supports the automatic IP route table maintenance of the RIP Protocol.
70. Rsync: Remote Sync Remote Data Backup daemon.
71. RSH: Start a shell on the remote host and execute USER commands.
72. rwhod: allows remote users to obtain a list of all logged-on users on the machines running the rwho daemon.
73. rstatd: A waiting process for other machines on the LAN to collect and provide system information.
74. ruserd: remote user location service, an RPC-based service that provides user information about a machine log currently recorded on the LAN
75. Rwalld: activates the rpc. rwall service process. This is an RPC-based service that allows users to write messages to each terminal registered on the LAN machine.
76. rwhod: activates the rwhod service process. It supports rwho and ruptime services of the LAN.
77. saslauthd: Use the SASL authentication daemon.
78. Sendmail: the sendmail daemon of the mail server.
79. SMB: Samba file sharing/printing service daemon.
80. snmpd: The local Simple Network Management daemon.
81. Squid: the squid daemon of the proxy server.
82. sshd: OpenSSH server daemon. Secure Shell protocol enables secure remote host management.
83. smartd: Self Monitor Analysis and Reporting Technology System, which monitors whether your hard disk is faulty.
84. syslog: a script that enables Syslog and klogd system logs to wait for processes during system boot.
85. Time: the daemon obtains the time and date from the remote host and uses the TCP protocol.
86. Time-udp: This daemon obtains the time and date from the remote host and uses UDP protocol.
87. Tux: run the daemon of the Apache server in the Linux kernel.
88. vsftpd: the daemon of the vsftpd server.
89. vncserver: VNC (Virtual Network Computing, Virtual Network Computing ).
90. XFS: X Window server daemon, which provides a font set for local and remote X servers.
91. xinetd: supports core daemon processes of multiple network services.
92. ypbind: activates the ypbind service process for the NIS (Network Information System) client.
93. yppasswdd: the NIS Password server daemon.
94. ypserv: the NIS master server daemon.
95. Yum: automatically upgrades the RPM operating system and manages the software package daemon.
You can determine whether to start a service based on your needs. For example, U and iptables must be run. Echo, echo-udp, daytime, daytime-udp, Chargen, and chargen-udp can be disabled for debugging. Commands such as RSH, rstatd, rsync, rusersd, and rwalld are all Berkley remote commands. They all start with the letter R and are called the R * command. It is mainly used to allow a user on a computer to remotely execute a program on another computer with the same account. Do not close the program to reduce potential risks. Innd is a process that runs newsgroup services. Do not close it.