我正在 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/