This section describes how to automatically start SVN when Linux is started. In the previous section, we will explain how to automatically start the SVN service when Windows is started. Through this section, you can make a comparison, let's take a look at the differences between Automatic startup of SVN in the two operating systems. I hope this section will help you learn more.
Configure svnserve on Redhat and implement version control through Myeclipse access. However, to enable the svn service, you can manually enter a command to start it. In this way, you have to re-enter the command every time you restart the server, which is too troublesome. So there is a new question: how can SVN be started as the server starts up?
First, let's take a look at the Linux automatic running program.
**** **************************************** ********
Automatically run the program in RedHatLinux
1. automatically run the program at startup
After Linux 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. 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 SVN 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. automatically run the program upon Logon
When a user logs on, bash automatically runs the global logon script:/ect/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. automatically run the program upon logon.
When you log out, bash automatically runs the personal logout script/. bash_logout. For example, if you add the command "tar-cvzfc.source.tgz *. c" to/. bash_logout, the "tar" command is automatically executed every time you log out to back up the *. c file.
4. Periodically run the program automatically
Linux has a daemon called crond. Its main function is to periodically check the content 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 creating a crondFile with the content "00923Jan * HappyBirthday" and running the "crontabcronFile" 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. automatically run the program once at a scheduled time
Scheduled command execution at is similar to crond (but it is only executed once): The command is executed at a given time, but is not automatically repeated. The at command is generally in the format of at [-ffile] time. All commands in the file are executed at the specified time. You can also enter the command directly from the keyboard:
$ At12: 00
At> mailtoRoger-s "Havealunch" Ctr-D
Job1at2000-11-0912: 00
2000-11-0912: at 00, an email titled "Havealunch" is automatically sent to Roger containing the plan.txt file.
#! /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 & #166; start & #166; stop }"
Exit1
Esac
Exit1
After writing the script, modify the chmodu + xtest. sh permission.
First, all the SVN service programs started randomly in linux are in/etc/init. d. All the files in this folder are script files (in simple words, the script program writes the program to be run to a file so that the system can execute it in order, similar to windows autorun. in addition, there are folders such as rc1.d, rc2.d to rc6.d In the/etc folder, which are different runlevels in linux, generally, the running level of multiple users in Xwindows is 5th, that is, rc5.d. The script file in this folder is the service program to be started randomly when the script file is 5th. Note that in each rc (1-6 ). the files in the d folder are all/etc/init. A soft connection to the files in the d folder (similar to the shortcut in windows), that is, in/etc/init. the d folder contains all the service programs, and each rc (1-6 ). d. Only link it to start the desired service program!
To start scim (a program), we first need to know where the scim program is. We can use the locate command to find it. scim is in/usr/bin/scim, usr indicates that it belongs to the user, and bin indicates that the program can be executed in linux. In this way, I can write a script program, put it in/etc/init. d, and then make a corresponding soft link in rc5.d.
This script is actually very simple, just two lines:
#! /Bin/bash
/Usr/bin/scim
The first line is to declare the terminal used to run the script, and the second line is the command to run.
Note that in rc5.d, the name of each link starts with S or K, K starts with a random start. In this way, you can know which service I want to start at random, and change the first letter K to S. Of course, after changing S to K, this service cannot start sVN at random. Therefore, we need to name this link SXXX so that the system can start it at random.
**** **************************************** ********
After learning about this, the procedure is simple.
1. Create the execution script svn. sh (/root path). The content is as follows:
#! /Bin/bash
Svnserve-d -- listen-port8080-r/home/svnroot/repository
2. Add executable permissions
Run the command line # chmodug + x/root/svn. sh
3. Add automatic run
Open (vi or gedit)/etc/init. d/rc. d/rc. local and add the following line at the end:/root/svn. sh save and exit.
4. Check
Restart the server and run ps-ef to check whether the svn process is started. Hey, the problem is fixed, and svn will be automatically started after it is started.
Author "xiaocao"