Laman

service init.d dan rc.d linux update-rc.d

agar script yang anda buat bisa berjalan saat sartup atau shutdown anda bisa gunakan update-rc.d dengan menyimpan file script anda di /etc/init.d/ dengna ketentuan sebagai berikut:

headernya seperti ini



#!/bin/bash
#
### BEGIN INIT INFO
# Provides:          passeko v1
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Should-Start:      $network $time
# Should-Stop:       $network $time
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: change password and send to telegram
# Description:       tes
### END INIT INFO
#


harus ada fungsi start() stop() reload() karena fungsi ini yang akan dieksekusi misal saat sartup isi fungsi start yang di eksekusi dan begitu juga stop.

start() {
   ....; ganti dengan script anda
}

stop() {
   ....;
}

reload() {
  ....
}


contoh sebagai berikut :

#!/bin/bash
#
### BEGIN INIT INFO
# Provides:          tes v1
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Should-Start:      $network $time
# Should-Stop:       $network $time
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: tes
# Description:       tes
### END INIT INFO
#
start() {
echo "hallow word";
}
stop() {
echo "stop jalan";
}
reload() {
echo "reload jalan";
}

case "${1:-''}" in
  'start')
start;
;;
  'stop')
stop;
;;
  'restart')
echo "restart";
;;
  'reload'|'force-reload')
reload;
;;
  *)
echo "Usage: $SELF start|stop|reload"
exit 1
;;
esac

exit 0

setelah anda membuat file tersebut tambah permission +x dengan perintah chmod +x file anda
dan terakhir jalankan dengan perintah update-rc.d fileanda defaults