LinuxParty
NUESTRO SITIO necesita la publicidad para costear hosting y el dominio. Por favor considera deshabilitar tu AdBlock en nuestro sitio. También puedes hacernos una donación entrando en linuxparty.es, en la columna de la derecha.
Si usted necesita algunas veces o siempre ciertos programas o scripts, este código comprueba si el programa o script se ha muerto! Momento en que volverá a ejecutarlo de nuevo.
Para estar seguros de esta función, basta con añadir el handler de bloqueo siguiente en la parte superior de la secuencia de comandos (antes de la funcionalidad del script principal):
También, puedes ver este código...

Para estar seguros de esta función, basta con añadir el handler de bloqueo siguiente en la parte superior de la secuencia de comandos (antes de la funcionalidad del script principal):
#!/bin/bash ######### Lock checker ########### myName="`echo $0 | awk '{print $NF}' FS='/'`" lockDir="/var/lock/" lockFile=$lockDir$myName.pid currentPID=$$ oldPID="`cat $lockFile`" oldderExist=` kill -0 $oldPID 2>/dev/null ; echo $? ` if [ "$oldderExist" == "0" ]; then echo "An Other Instance Is Running...! PID:$oldPID" ; exit
else echo $currentPID > $lockFile
fi ######### Lock checker ###########
También, puedes ver este código...
#!/bin/bash # don't use pid's they can be doubled in theory # Under *nix, process IDs are usually allocated on a sequential basis, # beginning at 0 and rising to a maximum value which varies from system to system. # -- see: cat /proc/sys/kernel/pid_max # Once this limit is reached, allocation restarts at 300 and again increases. # meanwhile if another proccess taken your stored PID-ID you get a double but # not the assumed proccess you where looking for! # use the kernel random generator function instead, the odds of creating # a few tens of trillions of UUIDs in a year and having one duplicate uuidkey=`cat /proc/sys/kernel/random/uuid` # better use /tmp for lockfiles, gets cleaned after reboot if tmpfs is used... lockfile=/tmp/${0##*/}.lock if test -f "$lockfile" then olduuid=`cat $lockfile |awk '{print $2}'` if [ "$olduuid" == "$uuidkey" ] then # LoL, this can never be right, one chance in a ... echo "This can't be right!, the same UUID's twice" echo "new: $uuidkey" echo "old: $olduuid" else gettimestamp=`cat $lockfile |awk '{print $1}'` echo "There is a lockfile, created at: `date -d@$gettimestamp`" exit 1 fi else echo "`date +%s` $uuidkey" > $lockfile fi # got here, put the rest of the script below...

-
Linux
- ¿Se toma en serio la privacidad en línea? Este sistema operativo Linux "en vivo" es para usted
- Linux supera el 5% de cuota de mercado según PornHub: Un crecimiento del 41% en 2024
- Linux 6.14 permite que algunos sistemas suspendan y reanuden más rápidamente
- Cómo mantener Linux optimizado (y ahorrar tiempo) con Stacer
- Cambiar la Hora y la Fecha al sistema Linux
- Montar un directorio remoto, vía NFS, en Linux
- Predicciones de Linux para 2025
- Elementary OS 8: una distribución de Linux para usuarios de Windows y macOS
- Renombrar multiples archivos masivamente en Linux (quitar espacios, cambiar mayúsculas) a la vez en Linux
- He utilizado Linux durante 30 años. Aquí hay 5 razones por las que nunca cambiaré a Windows o MacOS
- Mis predicciones sobre Linux para 2025: será un buen año
- ¿Por qué Torvalds eliminó a los encargados rusos del mantenimiento del núcleo de Linux?
- 10 cosas que siempre hago después de instalar Linux (y por qué tú también deberías hacerlo)
- 7 cosas que nunca hago después de instalar Linux (y por qué tú tampoco deberías)
- Detección de Intrusos: Snort, Base, MySQL, y Apache2 en Ubuntu Linux 7.10