Link to home
Start Free TrialLog in
Avatar of AXISHK
AXISHK

asked on

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,

Tks
Avatar of Mark Bullock
Mark Bullock
Flag of United States of America image

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.
https://access.redhat.com/articles/754933
Avatar of AXISHK
AXISHK

ASKER

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
    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



Tks
ASKER CERTIFIED SOLUTION
Avatar of Mark Bullock
Mark Bullock
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AXISHK

ASKER

Tks