How to set the automatic startup program on linux

Source: Internet
Author: User
In linux, set the automatic startup program. 1. after the program www.2cto. comLinux is loaded, it initializes the hardware and device drivers, and then runs the first process init. Init starts Other processes based on the configuration file. In general ,... in linux, how does one set the automatic startup program. after the program www.2cto.com Linux is automatically run at startup, it initializes the hardware and device driver, and then runs the first process init. Init starts Other processes based on the configuration file. Normally, the modification is placed in/etc/rc or/etc/rc. d or/etc/rc ?. The script file in the d directory can enable init to automatically start other programs. For example, to edit the/etc/rc. d/rc. local file, add "xinit" or "startx" at the end of the file. you can directly enter X-Window after the file is started. 2. when a user logs on to the system, bash automatically runs the global logon script:/etc/profile created by the system administrator. Bash then searches for one of the three special files in sequence in the user's starting Directory:/. bash_profile,/. bash_login, and/. profile, but only executes the first one found. Therefore, you only need to add commands to the above files as needed to automatically run certain programs (similar to Autoexec. bat in DOS) during user logon ). 3. when a program is automatically run to log out, bash automatically runs the personal logout script/. bash_logout. For example /. add the command "tar-cvzf c. source. tgz *. c ", the system will automatically execute the" tar "command to back up every time you log out *. c file. Www.2cto.com 4. the program runs automatically on a regular basis. in Linux, a daemon called crond is used to periodically check the contents of a group of command files in the/var/spool/cron directory, and execute the commands in these files at the specified time. You can use the crontab command to create, modify, and delete these command files. For example, after you create a crondFile with the content "00 9 23 Jan * HappyBirthday" and run the "crontab cronFile" command, the system automatically runs the "HappyBirthday" program ("*" indicates that no matter the day of the day is the day of the week) at AM on November 23, lunar January ). 5. timed automatic running of the program a scheduled command at is similar to crond (but it only runs once): The command is executed at a given time, but not automatically repeated. The at command is generally in the format of at [-f file] time. all commands in the file are executed at the specified time. You can also enter the command $ at 12 directly from the keyboard: 00at> mailto Roger-s "Have a lunch" <plan.txt at> Ctr-DJob 1 at, an email titled "Have a lunch" is automatically sent to the plan.txt file. roger. #! /Bin/bash RESTART = "........ "# write the corresponding service code START = "....... "STOP = ".......... "case" $1 "in restart) $ RESTART echo "...... "; start) $ START echo "...... "; STOP) $ STOP echo "...... "; *) echo" Usage: $0 {restart? Start? Stop} "exit 1 esac exit 1 after writing the script, you need to modify the permission chmod u + x test. sh.
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.