gpt4 book ai didi

linux - 将运行时日志存储在文件夹中

转载 作者:太空宇宙 更新时间:2023-11-04 03:49:49 24 4
gpt4 key购买 nike

我正在 Linux 环境中运行 shell 脚本来创建一些日志(动态日志文件)作为文本文件。

我想在某个特定时间后将创建的所有日志文件存储到一个文件夹中。

那么我该怎么做呢?谁能建议一些命令?

提前致谢。

最佳答案

在脚本中,您可以将该目录定义为变量,并且可以在整个脚本中使用该目录。

#!/bin/bash

LOG_DIR=/tmp/logs
LOG_FILE=$LOG_DIR/log_file.$$ ## $$ will create the different log file for each and every run
## You can also do it by using some time stamp using date command.

<Your commands> >> $LOG_FILE

关于linux - 将运行时日志存储在文件夹中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26730148/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com