Reference URL: http://unix.stackexchange.com/questions/20357/how-can-i-make-a-script-in-etc-init-d-start-at-boot
試過 It's work.
注意Script 内容格式,按下面写,如果发现not work 就检查script是否有错。名字可不加.sh, 如:tomcat都ok
If you are on a Red Hat based system, as you mentioned, you can do the following:
- Create a script and place in
/etc/init.d
(e.g/etc/init.d/myscript
). The script should have the following format:
#!/bin/bash# chkconfig: 2345 20 80# description: Description comes here....# Source function library../etc/init.d/functions
start(){# code to start app comes here # example: daemon program_name &}
stop(){# code to stop app comes here # example: killproc program_name}case"$1"in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)# code to check status of app comes here # example: status program_name;;*)
echo "Usage: $0 {start|stop|status|restart}"esac
exit 0
The format is pretty standard and you can view existing scripts in /etc/init.d
. You can then use the script like so /etc/init.d/myscript start
or chkconfig myscript start
. The ckconfig
man page explains the header of the script:
> This says that the script should be started in levels 2, 3, 4, and
> 5, that its start priority should be 20, and that its stop priority
> should be 80.
The example start, stop and status code uses helper functions defined in /etc/init.d/functions
-
Enable the script
$ chkconfig --add myscript $ chkconfig --level 2345 myscript on
-
Check the script is indeed enabled - you should see "on" for the levels you selected.
$ chkconfig --list | grep myscript
Hope this is what you were looking for.
相关推荐
cube.zip This example demonstrates how to rotate a cube in visual basic.<END><br>17 , sprite1.zip This is an Excellent example on how to use sprites in your program.<END><br>18 , charcreate.zip...
and how we harness generality and program to catch mistakes earlier. Along the way we encounter all the jargon — classes, inheritance, instances, linkage, methods, objects, polymorphisms, and more —...
Now, a message box is posted to indicate that a filter was found, and the program checks whether initialization is complete, at 1 second intervals. When the filter is done initializing, the VsGui ...
4.3.1 A Simple Spawn Controller..................................49 4.3.1.1 Script Breakdown................................52 4.3.2 Trigger Spawner...........................................56 4.3.3 ...
Just call CBCGPRibbonComboBox::EnableCalculator method to assign a calculator to the ribbon combobox. Override a new 'OnCalculatorUserCommand' method to implement your calculator commands. Please ...
How can we use a class Foo in a header file without access to its definition? We can declare data members of type Foo* or Foo&. We can declare (but not define) functions with arguments, and/or ...
demo.zip How to send debugging output to a console in a MFC application(12KB)<END><br>56,statuslog.zip A very simple text logger that allows you to use printf-type formatting, with automatic ...
would be a good idea to have a quick look at the demos. The library has been completely rewritten and a lot of new features has been added. ------------------------------------------- 4. Known ...
Before We Start 30 Our First C# Program 30 The Code 30 Compiling and Running the Program 31 Contents A Closer Look 31 Variables 34 Initialization of Variables 34 Variable Scope 35 Constants 38 ...
There are a few restrictions how the ARM instruction set is implemented. The changes are minor and mostly have a minor impact. For the most part the basic instruction outline is the same. Where ...
then program writes collected data to specified file. Log file is comma separated. Here is format: First line is the header line : Program name: File creation time,Target Address,Community string,...
Which MySQL utility program should you use to process and sort the slow query log based on query time or average query time? A. mysqlslow B. mysqldumpslow C. mysqlshow D. mysqldump E. mysqlaccess...
1.How to Activate Direct Posting to G/L Accounts and Material Account 605 2.What will Happen? 607 3.Mark delv. Completed 607 物料移动类型和后勤自动科目设置 608 分割评估和混合成本 620 业务背景: 620 ...
PEP 523: Adding a frame evaluation API to CPython PYTHONMALLOC environment variable DTrace and SystemTap probing support Other Language Changes New Modules secrets Improved Modules array ast ...
/* This is the same as current_location, but cast to a * memory_control_block */ struct mem_control_block *current_location_mcb; /* This is the memory location we will return. It will * be ...