I know how to direct the entire output of a cron job into a file, but I'm having trouble running a shell script that has multiple redirects within the file. So, my crontab entry is:
0 * * * * /bin/sh /path/to/script
Then, inside of /path/to/script, it calls two long-running commands and backgrounds them:
/path/to/command1 2>&1 >/path/to/output1 &
/path/to/command2 2>&1 >/path/to/output2 &
When I run /path/to/script from a bash shell, everything works correctly. When I run it via a cron job, output1 and output2 are created, but are blank, and the output is instead sent via cron email. I've tried "nohup command1", no luck either. How do I get the output to redirect to the files like I expect? Thanks!