redirect crontab file named using the date and time

Use the month named

0 12 * * * sh /tmp/test.sh >> "/tmp/$(date +"\%Y-\%m").log"  2>&1

  

Use named Zhou

0 12 * * * sh /tmp/test.sh >> "/tmp/$(date +"\%Y-W\%W").log" 2>&1

  

Hours name

0 12 * * * sh /tmp/test.sh >> "/tmp/$(date +"\%Y-\%m-\%d_\%H").log" 2>&1

  

2> & 1 represents the standard error and standard output redirection to a consistent output

Guess you like

Origin www.cnblogs.com/abclife/p/11184714.html
Recommended