From your comments above
/tmp/logfile_extract_$(date '+%Y-%m-%d-%H').txt
Is the problem 1) is / bin / sh really bash? I have seen operating systems where its โsomething more than like,โ and therefore the bash syntax can throw it.
0 */2 * * * /bin/bash -c '/tmp/sample.sh > /tmp/logfile_extract_$(date "+%Y-%m-%d-%H").txt 2>&1'
may work in this case. Or you can consider the backlink or shell script called from cron, which simply executes
/tmp/sample.sh > /tmp/logfile_extract_$(date "+%Y-%m-%d-%H").txt 2>&1
source share