Récupérer le pid d'une commande java lancée via un sh
Bonjour,
J'ai un .sh qui me sert à lancer une commande java. J'aimerais au démarrage récupérer le pid de la commande java et l'afficher dans la console
au démarrage. J'ai cherché sur le net et tenté de passer par plusieurs méthode mais sans succes.
Voici le code de la fonction executant la commande java dans mon script:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
start_module() {
echo "$(date +"%Y-%m-%d %H:%M:%S %s") : START_MODULE - Starting ${module} instance ${instance}..." >> ${console} 2>&1
echo -e "\033[0;37m$(date +"%Y-%m-%d %H:%M:%S %s") \033[0;35m+\033[0;37m START_MODULE - Starting ${module} instance ${instance}"
tput sgr0
cd ${path}
${command} >> ${console} 2>&1
export ERRORLEVEL=$?
if [ "${ERRORLEVEL}" -eq "0" ]; then
echo "$(date +"%Y-%m-%d %H:%M:%S %s") : START_MODULE - END ${module} instance ${instance} WITHOUT ERROR" >> ${console} 2>&1
echo -e "\033[0;37m$(date +"%Y-%m-%d %H:%M:%S %s") \033[0;35m+\033[0;37m START_MODULE - END ${module} instance ${instance} WITHOUT ERROR"
tput sgr0
return 0
else
echo -e "\033[0;37m$(date +"%Y-%m-%d %H:%M:%S %s") \033[0;35m+\033[0;37m START_MODULE - ALERT - END ${module} instance ${instance} WITH ERRORLEVEL = ${ERRORLEVEL}"
echo -e "\033[0;37m$(date +"%Y-%m-%d %H:%M:%S %s") \033[0;35m+\033[0;37m START_MODULE - Command was ${command}"
tput sgr0
echo "$(date +"%Y-%m-%d %H:%M:%S %s") : START_MODULE - ALERT - END ${module} instance ${instance} WITH ERRORLEVEL = ${ERRORLEVEL}" >> ${console} 2>&1
echo "$(date +"%Y-%m-%d %H:%M:%S %s") : START_MODULE - Command was ${command}" >> ${console} 2>&1
return 1
fi
} |
Merci pour vos conseils