bash: script running in pm2 unable to access file descriptors files at /dev/fd/
1
vote
1
answer
217
views
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/
- Previous discussion: https://stackoverflow.com/questions/78885319/bash-redirecting-to-multiple-file-descriptors
- For reference : https://unix.stackexchange.com/questions/26926/file-descriptors-and-dev-fd
Asked by Amith
(313 rep)
Aug 23, 2024, 11:08 AM
Last activity: Sep 3, 2024, 10:24 AM
Last activity: Sep 3, 2024, 10:24 AM