I have script script.sh:
#!/usr/bin/env bash # pm2 seems to always run in `bash` regardless of `#!` echo "running in $(readlink -f /proc/$$/exe)" # Redirect to both stdout(1) and stderr(2) echo "hello" | tee /dev/fd/2 I am running it with pm2 start script.sh
I can see logs at pm2 logs like so:
tee: /dev/fd/2: No such device or address Which means script is unable to access /dev/fd. Although this problem doesn't happen when directly running in a bash terminal.
- About
pm2: https://pm2.keymetrics.io/docs/usage/quick-start/ - previousPrevious discussion: https://stackoverflow.com/questions/78885319/bash-redirecting-to-multiple-file-descriptors
- For reference : file descriptors and /dev/fd