I have not posted a post for a long time since I started frintf on ubuntu. I have summarized a small job that has been busy for a few days. A project similar to a server was created some time ago, that is, to write a piece of code on the server, the main use of which is data transfer. Using the ubuntu-10.04 server version ....
I have not posted a post for a long time since I started frintf on ubuntu. I have summarized a small job that has been busy for a few days. A project similar to a server was created some time ago, that is, to write a piece of code on the server, the main use of which is data transfer. The ubuntu-10.04 server version is used. Www.2cto.com
After writing the code, you need to enable the program to start automatically. Previously, on the embedded cpu, you can directly modify the inittab file. However, ubuntu does not seem to have this file, instead it is replaced by a bunch of rcx. d directories. Google may not be used in the past few days. Baidu. View many posts. To learn about the startup level of linux.
Rc (x ). d. The folder stores the script link of the corresponding service running in Level x, that is, the scripts that need to be executed by the system under the six running levels are put in six different directories: rc0.d, rc1.d, rc2.d, rc3.d, rc4.d, rc5.d, and rc6.d. Many of the script files in these directories are files under the init. d Directory. the soft connection 0 is stopped, and the machine is disabled. 1 is the single-user mode, just like the security mode in Win9x. 2: Multi-user mode, but not supported by NFS. 3 is a complete multi-user mode, which is a standard operation level. 4. Generally, you can use it to do things in some special cases. For example, you can switch to this mode to make some settings when the battery of your laptop is exhausted. 5 is X11, and it enters the X Window System. 6. restart the init 6 server. Run runlevel on my machine terminal. 2 indicates that the current running level is 2. Then, write your own script according to the example provided on the Internet. Create your own script commu under the/etc/init. d/directory and modify the attributes to add executable permissions. Then, create a soft connection to the file in the rc2.d directory. Ln-s/etc/init. d/commu/etc/rc2.d/S99commu (S: start execution 99: Execution order commu: file name ).
Then restart and stop at the logon page. there is no output. It looks like no execution. Because I have printed a huge amount of output in my code. I did not study it carefully and thought that my program was not executed. Then add the startup script before exit in the/etc/rc. d/rc. local file. Restart. there is no output. If I add it everywhere, I will not execute it. Later I thought about it myself. Is it executed? I just didn't print the output. In my code, there is a simple web configuration interface written by myself. Connect to the network cable, open ie in the pc, enter ip: Port, successfully open. Indicates that the program is running. Then, follow the initial method to establish a soft connection to the script file in the rc2.d directory. It can also run. This method is feasible. But another question comes. Where can I print it? I want to see the process. I probably know that the background operation is not interactive, and then I found that the last logon interface is tty1, then I asked my program to print the standard output and standard error to tty1 in the script. Then add 1>/dev/tty1>/dev/tty1. restart the program in the script. Still not, depressed.
Later I found out the concept of console definition: What is the console? We often say that the console refers to the console terminal (/dev/ttyn, console, in UNIX systems, the computer display is called the console terminal ). Generally, a pc, a display, and a keyboard form a console. In addition, the console terminal is associated with some special device files: tty0, tty1, and tty2... Ttyn is usually associated with/dev/console and tty0. Modify the startup parameter 1>/dev/console 2>/dev/console in the startup script, restart, and print it. Continue to set the startup parameter to 1>/dev/tty0 2>/dev/tty0, and restart the system. the print content is also displayed. Done.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.