Send Stderr And Stdout To A Log File
If you want to overwrite the log file each time you start your command:
parity [options] > /tmp/parity.log 2>&1
If you want to append to your log file each time you start your command:
parity [options] >> /tmp/parity.log 2>&1
Send Stderr And Stdout To Separate Log Files While Viewing Output
And if you want to log stderr and stdout into separate log files while viewing the output on your console:
parity [options] > >(tee stdout.log) 2> >(tee stderr.log >&2)
Reference How do I write stderr to a file while using “tee” with a pipe?How do I write stderr to a file while using “tee” with a pipe?.
If you want to create a script file to run this command, you will have to use #!/bin/bash
(instead of #!/bin/sh
) in the first line of the file as this redirection is bash specific:
#!/bin/bash
cd $HOME/Parity
parity [options] > >(tee stdout.log) 2> >(tee stderr.log >&2)
Save the above into $HOME/bin/runParity
, chmod 700 $HOME/bin/runParity
and your can then type runParity
(or $HOME/bin/runParity
) to start it.