Affichage des articles dont le libellé est startup. Afficher tous les articles
Affichage des articles dont le libellé est startup. Afficher tous les articles

mardi 28 juin 2016

Start a program when os start up Centos 7


When you have a server, this is good that a program is up at boot time. In order to do this, you should have a script to start the application/server in the /etc/init.d/ folder 

To create a script of your own, best is to copy some existing files and adapt it. The main idea is that the script should allow to start, stop and give the status of the application

For instance, lets consider a program starting a apache-ds LDAP. 


!/bin/bash
# Source function library.
. /etc/rc.d/init.d/functions
# Can specify the run levels on the chkconfig line where the program is activated here the program is activated at level 3, 4 and 5 
# Where the run level are the standard linux 3 is multi user, 4 is rarely used, 5 multi user with graphic.
# Then 99 is the start priority (99 is the least, in that case  Apache LDAP will be started after all other program has been started. 
# Then 99 is the stop priority (01 is the highest priority, in that case  Apache LDAP will be stopped the first . 
# chkconfig: 345 99 01
# description:  LDAP startup script
 
start() {
runuser -  ldap -c "cd /home/ldap/apacheds-2/;bin/apacheds.sh default start"
}
 
stop() {
runuser -  ldap -c "cd /home/ldap/apacheds-2/;bin/apacheds.sh default stop"
}
 
 
status() {
runuser -  ldap -c "cd /home/ldap/apacheds-2/;bin/apacheds.sh default status"
}
 
 
# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status
        ;;
  *)
        echo $"Usage: $0 {start|stop|status}"
        exit 2
esac
 
exit $?

Once you have created this script, you should add it to the list of service 
 
# chkconfig --add apacheds

It will create some files in /etc/rc3.d, /etc/rc4.d, /etc/rc5.d

To check this you can pass the command. 
 # chkconfig --list apacheds
 
apacheds        0:off   1:off   2:off   3:on    4:on    5:on    6:off


vendredi 2 décembre 2011

Update Grub in Ubuntu

In order to start have your windows first in your Ubuntu 11.10, just change the order of the files in /etc/grub.d by changing the number starting each entry.

By default, the directory contains the files : 00_header, 01_linux, 02_linux_xen, 03_os_probe etc.
If you change the file names so that numbers looks like 00_header, 01_os_probe, 02_linux, 03_linux_xen

And then run grub-update (to update /boot/grub/grub.cfg) in command line. Windows will launch first at startup.

mardi 14 octobre 2008

Démarrage des programmes au boot

Le fichier /etc/initab définit le niveau désiré.

3: Sans écran, multiutilisateur, cela permet un demarrage plus rapide et économise les ressources nécessaire pour le X. Utile pour un serveur.
5: Avec le démarrage du mode graphique, c'est le mode par défaut.

Pour démarrer un programme automatiquement :

Créer le fichier de démarrage dans /etc/rc.d/rcX.d/ ou X est le niveau du démarrage.

Pour le démarrage, il faut préfixer le nom du fichier de S et donner un numéro de séquence.

Pour l'extinction, il faut préfixer le nom du fichier de K et donner un numéro de séquence.

Ne pas oublier si le fichier .depend.start de renseigner les dépendances.