Home  >  Q&A  >  body text

linux - nohup 2>&1输出日志

阿神阿神2743 days ago892

reply all(2)I'll reply

  • 阿神

    阿神2017-04-17 17:09:13

    Execution order issue, the code inside "``" is executed first, and the execution result is nested in the outer command as a string

    eventually became

    nohup python demo.py > /data/log_2017-04-10_.log 2>&1 &

    Through the ps command you can see that there is only one process python demo.pyps命令你可以看到只有一个进程python demo.py

    即使过了00:00

    Even after 00:00, the PID of the process will not change🎜

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 17:09:13

    Use crontab to execute scheduled tasks,
    There are two methods to handle it

    1. Kill the process regularly every day and re-execute your command

    2. Fix the file name of a log and rename the log file according to date regularly every day.
      The second method does not require stopping the application, but you can also customize the granularity of the log files yourself. You can have one file per hour~

    reply
    0
  • Cancelreply