Linux--Ubuntu script boot from boot

Source: Internet
Author: User

There is a script that wants to run automatically when the Ubuntu virtual machine is powered on.

Creating a script file

Create a new script file under "/opt/lampp/": lampp_start.sh

#!/bin/bash/opt/lampp/lampp start

Edit Startup file

Add the self-startup script directory in the first line of the Do_start () function of the/etc/init.d/rc.local file, in the format path &>/dev/null &

Note:

1. Make sure it is the root user

2. Ensure that the script file access rights are executable files

This will enable your script to start automatically, and can be automatically restarted (kill the main process manually, not the main process to exit after the error)

The knowledge points involved 1. About &>/dev/null

First of all: in Linux/unix, the information generally seen on the screen is from stdout (standard output) or stderr (standard error Output). Many people will ask, output is output, sent to the screen does not have, why should be divided into stdout and stderr it ? That's because in the server's working environment, almost all of the programs are run in background, so, in order to facilitate debug, generally in the design process, the stdout to a document, the wrong information stderr saved to different files.
• What are normal output, such as the time the program started running, the number of people who are now online, and so on.
• What are the wrong output, such as the inability to find the URL that the user wants to go to, or the failure of the credit card authentication?
With these perceptions, what is >/dev/null?
>/dev/null. is to send stdout to/dev/null inside,/dev/null is unix/linux "bottomless pit" any output sent to the "bottomless pit" will no longer. Trust me, it's gone!
In general, if you do not want to see output or output too much, it is possible to squeeze the hard disk, the design of the program will consider to send output to/dev/null. Of course, I believe you are more looking forward to redirecting some of the program output to the specified file for use as a log file. redirect the > symbol is used to redirect the output to the specified file, overwriting the original content (the original content disappears) the;>> symbol will insert the output to the left of the symbol to the end of the right side of the content is not very intimate?

2. Why Choose Rc.local file? This is the user to customize the boot program, the need to start the automatic operation of the program written in this script, in the last phase of Linux boot, the system will execute the command stored in rc.local. It's a bit like the Start menu inside windows, but it's more cumbersome and more powerful.

Linux--Ubuntu script boot from boot

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.