I need to redirect the output of a command that I am running to a log file with timestamp (hence a function instead of the log file itself) but the error and the output, both should not be showing in the console. The following -
command | my_func 2> /dev/null
is not working.
Something like
command 2> logfile
works, but I can't record the timestamp in the second case. What should I do?