Création d'un service
De wiki_pcwiki2
Aller à la navigationAller à la recherche
KEYWORDS UNIX, SERVICE, CRÉATION, SUPPRESSION, RC.LOCAL
Le 03/11/2022: Méthode encore plus simple: https://www.cyberciti.biz/faq/how-to-enable-rc-local-shell-script-on-systemd-while-booting-linux-system/
Le 23/01/2020: Exemple pour ajouter un rc.local à un debian stretch (ce service n'est plus défini à partir de debian 9) vi /etc/systemd/system/rc-local.service et y placer ce contenu:
# /etc/systemd/system/rc-local.service # Ajouté par PC le 23/01/2020 car il n'y a pas de rc.local sous Stretch [Unit] Description=/etc/rc.local ConditionPathExists=/etc/rc.local [Service] Type=forking ExecStart=/bin/bash /etc/rc.local TimeoutSec=0 StandardOutput=tty RemainAfterExit=yes SysVStartPriority=99 [Install] WantedBy=multi-user.target # Script à lancer pour valider ce nouveau service: #_ #!/bin/sh -e #_ # #_ echo "# rc.local #_ # #_ # This script is executed at the end of each multiuser runlevel. #_ # Make sure that the script will exit 0 on success or any other #_ # value on error. #_ # #_ # In order to enable or disable this script just change the execution #_ # bits. #_ # #_ # By default this script does nothing. #_ #_ echo \"proof of rc.local running\" > /tmp/proofOfRc-localIsAlive #_ exit 0" > /etc/rc.local #_ chmod +x /etc/systemd/system/rc-local.service #_ chmod +x /etc/rc.local #_ systemctl enable rc-local #_ systemctl start rc-local.service #_ systemctl status rc-local.service
Le 23/01/2020: J'ai créé le service rc-local.service et j'y ai mis parfois le fstrim: - srv17: chmod +aw /dev/kvm - srv08: rien - srvbd08: rien - srv05: rien - srv14: rien - debian9-voilou: fstrim -av - debian9-pcwiki: fstrim -av - debian9-sources: fstrim -av - debian9-modele: fstrim -av - debian9-test: fstrim -av PS: regarder /tmp/proofOfRc-localIsAlive