Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

script init kill kille tout !! Please help je deviens fou...

1 réponse
Avatar
projlin
pour info

uname -a
Linux paloma 2.6.9-11.EL #1 Wed Jun 8 19:37:44 EEST 2005 i686 i686 i386
GNU/Linux
Red Hat Enterprise Linux AS release 4 (Nahant)
au cas ou...

Une histoire de fou

Je mets ce script dans /etc/rc.d/init.d/runtest

--------------------------------------------------------------------

case $1 in
'start')

# Get core dumps
ulimit -c unlimited
echo "Starting ..."
touch /var/lock/subsys/the_test

/bin/bash /usr/sctest &
;;
'stop')
echo "Killing ..."
;;
*)
echo "usage: /etc/rc.d/init.d/runtest {start|stop}"
;;
esac

--------------------------------------------------------------------

Et celui la dans /usr/sctest

--------------------------------------------------------------------

#!/bin/sh


### Loop on board until normal end of command
run_again=3D1
while [ ${run_again} =3D 1 ]
do

/bin/ping 127.0.0.1 > /avoir.txt

status=3D$?

if [ ${status} =3D 0 ]
then
run_again=3D0
else
echo ""
echo " - $$ - ${date}"
echo "Command has died with status ${status} !!!"
echo "It will be run again in 10 seconds..."
/bin/sleep 10
fi

done


exit 0

--------------------------------------------------------------------

je me met dans /etc/rc5.d
et je fais un liens symbolique

ln -s /etc/rc.d/init.d/runtest S99runtest


Je fait un test en tapant

/etc/rc5.d/S99runtest start

La si je fait un kill du ping il se relance bien au bout de 10
secondes.

Maintenant mon histoire de FOU !!

Je reboote mon serveur linux

Je fais un ps -ax

2013 ? S 0:00 /bin/bash /usr/sctest
2015 ? S 0:00 /bin/ping 127.0.0.1

Je fait un kill 2015

Et BOUM j'ai 2015 et 2013 qui meurent !!!
Bonjour mon script de relance...

Par contre quand je lance en faisant /etc/rc5.d/S99runtest start
Ca marche bien !!!

Merci de m'aider je ne comprends pas pourquoi quand init lance ce
script =E7a marche pas.

1 réponse

Avatar
projlin
Je me répond a moi meme pour que cela serve aux autres :

en fait quand un process essaie de faire une sortie sur la sortie
standard
vu qu'il est lancer par init il n'y a pas de sortie standard d'ouverte
et le process
moeurs en prenant un SIGPIPE !!!

pour eviter cela je lance mon script en faisant

script 1>>/dev/console 2>>/dev/console

voilà




pour info

uname -a
Linux paloma 2.6.9-11.EL #1 Wed Jun 8 19:37:44 EEST 2005 i686 i686 i386
GNU/Linux
Red Hat Enterprise Linux AS release 4 (Nahant)
au cas ou...

Une histoire de fou

Je mets ce script dans /etc/rc.d/init.d/runtest

--------------------------------------------------------------------

case $1 in
'start')

# Get core dumps
ulimit -c unlimited
echo "Starting ..."
touch /var/lock/subsys/the_test

/bin/bash /usr/sctest &
;;
'stop')
echo "Killing ..."
;;
*)
echo "usage: /etc/rc.d/init.d/runtest {start|stop}"
;;
esac

--------------------------------------------------------------------

Et celui la dans /usr/sctest

--------------------------------------------------------------------

#!/bin/sh


### Loop on board until normal end of command
run_again=1
while [ ${run_again} = 1 ]
do

/bin/ping 127.0.0.1 > /avoir.txt

status=$?

if [ ${status} = 0 ]
then
run_again=0
else
echo ""
echo " - $$ - ${date}"
echo "Command has died with status ${status} !!!"
echo "It will be run again in 10 seconds..."
/bin/sleep 10
fi

done


exit 0

--------------------------------------------------------------------

je me met dans /etc/rc5.d
et je fais un liens symbolique

ln -s /etc/rc.d/init.d/runtest S99runtest


Je fait un test en tapant

/etc/rc5.d/S99runtest start

La si je fait un kill du ping il se relance bien au bout de 10
secondes.

Maintenant mon histoire de FOU !!

Je reboote mon serveur linux

Je fais un ps -ax

2013 ? S 0:00 /bin/bash /usr/sctest
2015 ? S 0:00 /bin/ping 127.0.0.1

Je fait un kill 2015

Et BOUM j'ai 2015 et 2013 qui meurent !!!
Bonjour mon script de relance...

Par contre quand je lance en faisant /etc/rc5.d/S99runtest start
Ca marche bien !!!

Merci de m'aider je ne comprends pas pourquoi quand init lance ce
script ça marche pas.