Skip to content

Instantly share code, notes, and snippets.

@ogiovannyoliveira
Last active January 19, 2021 13:28
Show Gist options
  • Save ogiovannyoliveira/34d014fe568dd6f39a5c2206e01f0383 to your computer and use it in GitHub Desktop.
Save ogiovannyoliveira/34d014fe568dd6f39a5c2206e01f0383 to your computer and use it in GitHub Desktop.
Criando serviço simples no Linux para inicializar automaticamente junto com o sistema

Adicionando initscript

  1. Criar o arquivo de script em /etc/init.d/
nano /etc/init.d/anotherScript

anotherScript é apenas um nome fictício. Dentro desse arquivo deverá conter os comandos que serão usados por você, como por exemplo:

#!/bin/sh
echo "Teste" >> /home/arquivo.txt
  1. Tornar o script executável
chmod ugo+x /etc/init.d/anotherScript
  1. Configurar a inicialização do sistema para rodar o script
update-rc.d anotherScript defaults
  1. Iniciar seu serviço
service anotherScript start
  1. Checar o status do serviço
systemctl status textScript.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment