Startup script in RedHat

For those scripts saved under /etc/rc.d/init.d in RedHat, will it start automatically, or I still need to issue command "service Myscript start" to start it,

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mark BullockQA EngineerCommented:
If you are using init.d, they will start automatically. That's for older versions of red hat.

The latest version of red hat uses systemd.

This page tells you the differences and how to transition from init to systemd.
AXISHKAuthor Commented:
For those of the script (daemon), how to convert it to suppor the new format :
systemctl start myscript.service

Is there any format to follow for the .service file ?  For the script such as xxx.service, xxxx.mount, is there any format that I need to follow ?

I have attached a standard service script in my current RedHat :

# 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
       # code to check status of app comes here
       # example: status program_name
       echo "Usage: $0 {start|stop|status|restart}"

exit 0

Mark BullockQA EngineerCommented:
Here's a simple example for a daemon program.
touch /etc/systemd/system/program_name.service
chmod 664 /etc/systemd/system/program_name.service

Open in new window

Replace name with a name of the service to be created. Note that file does not need to be executable.
Open the name.service file created in the previous step, and add the service configuration options.

 The following is an example unit configuration for a network-related service:



Open in new window

For details, this page is helpful.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
systemd in CentOS7 supports SystemV init scripts exactly like upstart in CentOS6, no need to rewrite in some brain damage that will not run on any other system in future.

init.d scripts will work - any executable file in init.d directory will be started and stopped with system, probably you can improve over that by setting proper runlevel headers in your script and using chkconfig --add service and service start/stop
AXISHKAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.