Truncating a file while it's being used (Linux)

后端 未结 13 2133
名媛妹妹
名媛妹妹 2020-12-05 01:54

I have a process that\'s writing a lot of data to stdout, which I\'m redirecting to a log file. I\'d like to limit the size of the file by occasionally copying the current

13条回答
  •  南方客
    南方客 (楼主)
    2020-12-05 02:34

    I had a similar problem and was unable to do a "tail -f" on the output of a script that was run from cron:

        * * * * * my_script >> /var/log/my_script.log 2>&1
    

    I fixed it by changing the stderr redirect:

        * * * * * my_script >> /var/log/my_script.log 2>/var/log/my_script.err
    

提交回复
热议问题