How the Linux system starts automatically when the program is powered on

Source: Internet
Author: User

how the Linux system will automatically start the core prompt when the program starts: The system's service can be started automatically when booting, that under the Linux system if you want the program to start automatically when booting how to do? We know that in the Windows system "start"-"All Programs"--"start" put a shortcut on the line, the Linux system? ... The service of the system can be started automatically when booting, that under the Linux system if want the program to start automatically when starting to do? We know in Windows system "start"-"All Programs"-"Launch" inside a shortcut is OK, that Linux system? This is also a relatively simple problem, there are many ways to solve, here are three ways to introduce. Because it is a simple introduction, so the details are not very detailed, you can see the manual through the man. First,/etc/Rc.local This is one of the simplest ways to edit "/etc/rc.local ", enter the shell command for the startup program (to enter the full path of the command), similar to" Startup "under Windows. Using CommandsVI/etc/Rc.local then adds the full path of the program to execute on the last line of the file. For example, a haha is executed each time it is powered on.SH, this script is placed below the/opt, so you can add a line to "/etc/rc.local"/opt/./haha.SH", or two lines of" cd/opt "and"./haha. "SH". Second, crontab (similar to the Windows Task Scheduler service) through Crontab can set the program execution schedule, for example, let the program at 8 points per day, or 10 points per Monday. Crontab-l list timetable; Crontab-e edit timetable; crontab-d Delete the timesheet;-L "Nothing to say, just a look;"-E "is the editor, and VI no difference (in fact, with VI editing a specific file);"-D "is basically not used, because it removes all of the user's schedules, and is usually"-E "Edit to remove the time-line of the timetable, how to edit it? The format of the crontab file is: M H d M D CMD. A 6 field, where the last cmd is the program to execute, such as haha.SH. M: Minutes (0- -) H: Hours (0- at) D: Date (1- to) M: Month (1- A) d: One day of the one week (0-6, 0 for Sunday) These 5 time fields are separated by a space with a value that can be a number, or multiple digits separated by commas (or other), and, if not set, the default is "*". For example, haha is executed 8:5 every day.SHIs5 8* * * */opt/./haha.SH". As if and "boot program automatically start" Pull away, now return to the point. In fact, the above introduction of the CRONTAB function has been equipped with the ability to boot automatically, you can write a monitoring script, every 5 minutes to execute (*/5* * * *./haha.SHIf the program is not present, restart it once. (*/5) indicates that every 5 minutes three, the registration system service operating system comes with the service, such as SSH,FTP, etc., the boot is automatically started, we can also use this way to develop their own programs to improve the "price." For example, if I want to add a service that is already installed as a system service, you can execute the following command: Chkconfig--Add service Name (first, added as system service, note that add is preceded by two bars) Chkconfig-leve start level service name on (description, Level 3 is started in the command line mode, Level 5 represents start on the graphical interface, on indicates on) Chkconfig-leve boot level service name off (description, off indicates off self-booting) For example: Chkconfig-level3MySQL on (note: Let MySQL service in command-line mode, with system boot) can also use Chkconfig--Add service name to remove system service******************************************************************************************If you want to see which services are added as system services, you can use the command: NTSYSV or Chkconfig--list If you want to see which programs are added as self-booting, you can use the command:Cat/etc/rc.local (see which program paths are added to this file)*******************************************************************************************For example, how to add a shell script as a system service and follow the system boot: You can see "/etc/rc.d/INIT.D "There are a lot of files, every file can see the content, in fact, are some shell script." The start of the system service is through the/etc/rc.d/INIT.D "is implemented in the script file in the. We can also write a script of our own to put here. The contents of the script file are also very simple, similar to this (for example, a name called "Hahad"):. /etc/init.d/Functionsstart () {Echo "starting my process"CD/opt./haha.SH}stop () {Killallhaha.SH        Echo "stoped"after you have written the script file, you are done with the following steps:chmod+x Hahad #增加执行权限chkconfig--add Hahad #把hahad添加到系统服务列表chkconfig hahad on #设定hahad的开关/off) chkconfig--List Hahad #就可以看到已经注册了hahad的服务 finished all the work at this time. 

How the Linux system starts automatically when the program is powered on

Related Article

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.