Sample Header Ad - 728x90

How to run start up scripts on Amazon linux?

7 votes
1 answer
3461 views
I'm trying to create some script that should run on start. Now I've created some myScript file under the /etc/init.d/ and then run sudo chkconfig --add myScript; chkconfig --list myScript output is:
myScript 0:off 1:off 2:on 3:on 4:on 5:on 6:off **myScript:** #!/bin/sh # chkconfig: 2345 98 02 # description: # processname: # Source function library. if [ -f /etc/init.d/functions ] ; then . /etc/init.d/functions elif [ -f /etc/rc.d/init.d/functions ] ; then . /etc/rc.d/init.d/functions else exit 0 fi KIND="_" start() { echo starting date >> ~/myScript.log } stop() { echo stopping myScript } restart() { echo restarting } case "$1" in start) start ;; stop) stop ;; restart) restart ;; *) echo $"Usage: $0 {start|stop|restart}" exit 1 esac exit $? Now I can successfully run service myScript start and log record will be appended. But if I run sudo reboot or restart the instance with AWS UI console it doesn't work as was expected. Although runlevel output is:
N 3 Need some help.
Asked by Silk0vsky (213 rep)
Nov 15, 2016, 11:19 AM
Last activity: Aug 4, 2025, 09:09 PM