Pular para o conteúdo

Script sh na inicialização CentOS 7 [RESOLVIDO]

Responder tópico
  • Denunciar
  • Indicar

1. Script sh na inicialização CentOS 7 [RESOLVIDO]

Enviado em 14/03/2018 - 12:13h

Pesssoal

Pesquisei aqui, pesquisei no pai google, porem os exemplos colocados não surtiram efeito.
O que eu preciso é o seguinte:
é escrever um parâmetro "1" no arquivo /proc/sys/net/ipv4/tcp_tw_recycle toda vez que o sistema seja reiniciado, pois quando o sistema reinicia ele volta pro original que é "0"

ja tentei de todas as formas colocar um script simples:

#/bin/bash
echo "1" >> /proc/sys/net/ipv4/tcp_tw_recycle
echo "1" >> /proc/sys/net/ipv4/tcp_tw_reuse


Alguém com uma dica?

Responder tópico

3. Re: Script sh na inicialização CentOS 7 [RESOLVIDO]

Enviado em 15/03/2018 - 10:49h



como adptaria o script acima nesse exemplo nao consigo ver isso.
tem alguma dica?!

4. Re: Script sh na inicialização CentOS 7 [RESOLVIDO]

Enviado em 15/03/2018 - 10:59h

/usr/bin/local/myservice.sh


#!/bin/bash

function start()
{
echo "Starting...."
[...] seus comandos [...]
}

function stop()
{
echo "Stop"
[...] seus comandos [...]
}

[...] suas funções diferentes [...]

if [ "$1" == "start" ]; then

[...] seus argumentos [...]

fi


/etc/systemd/system/myservice.service


[Unit]
Description = My Service
After network.target = audit.service

[Service]
Type = forking
ExecStart = /usr/local/bin/myservice.sh

[Install]
WantedBy = multi-user.target



Segundo ao site... Isso.

/dev/disk0s1 is mounted.

5. Re: Script sh na inicialização CentOS 7 [RESOLVIDO]

Enviado em 19/03/2018 - 12:00h

é darwin não deu certo não !!!
eu já tinha testado com outros diretórios mais não funcionou não.

6. Re: Script sh na inicialização CentOS 7

Enviado em 19/03/2018 - 13:06h

Você pode utilizar o rc.local.

# ls -lh /etc/rc.local
lrwxrwxrwx 1 root root 13 Mar 12 18:26 /etc/rc.local -> rc.d/rc.local 

# chmod +x /etc/rc.d/rc.local
# vim /etc/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In constrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

echo "1" > /proc/sys/net/ipv4/tcp_tw_recycle
echo "1" > /proc/sys/net/ipv4/tcp_tw_reuse

touch /var/lock/subsys/local


7. Re: Script sh na inicialização CentOS 7 [RESOLVIDO]

Enviado em 19/03/2018 - 14:52h

amarildosertorio escreveu:

Você pode utilizar o rc.local.
...

touch /var/lock/subsys/local[/code]


Consegui man! na verdade era permissão mesmo!
criei um diretório na raiz /rotinas/ e com permissão full e funcionou.

vlw pelas dicas

Responder tópico

Responder tópico

Entre na sua conta para responder.

Fazer login para responder