Enregistrer tous les textes et erreurs d'un script
Publié le 06/12/2018 Bash
#!/bin/bash # Log all the STDOUT and STDERR from the script in debug.log file exec > >(tee -a "$HOME/debug.log") 2>&1
Le fichier $HOME/debug.log sera automatiquement créé et remplacé et amendé.
Pour remplacer le contenu du fichier à chaque exécution, il faut utiliser :
!/bin/bash # Log all the STDOUT and STDERR from the script in debug.log file exec > >(tee "$HOME/debug.log") 2>&1
Issu de https://unix.stackexchange.com/a/61936