How to redirect complete output of a cron script

前端 未结 4 523
星月不相逢
星月不相逢 2021-01-03 07:13

I have a simple cronjob running every day at 18:35:

05 18 * * * ~/job.sh 2>&1 >> ~/job.log

So the output of ~/job.sh should be

4条回答
  •  别那么骄傲
    2021-01-03 07:31

    I'm quite sure that this should work in a general case. The stdout file descriptor is changed by the OS when you use shell redirection.

    However, if your Python script itself directly writes to the screen (perhaps by opening /dev/tty), it won't get captured in your log.txt. Is that the case? Does it fail even for a simple python program that just does a

    print "Hello"
    

    ?

提交回复
热议问题