I've used this answer, which only copies stdout to file:
$ cat /etc/dehydrated/syncNexusCertificatesHook.sh
#!/bin/bash -ex
exec &> >(ts '[%Y-%m-%d %H:%M:%S]' | tee -a /var/log/dehydrated.log >&2 )
...
When running the script, there was a perl: warning: Setting locale failed.
printed to the terminal, but not to the log file.
I want to have all output from the script printed with a timestamp printed to the console as well as saved to the log file. How can I achieve this?