【问题标题】:RM output log with timestamp in crontab在 crontab 中带有时间戳的 RM 输出日志
【发布时间】:2020-04-20 02:08:28
【问题描述】:

如何在 crontab 中运行 RM 时为详细标志添加时间戳?

0 06 * * *  rm -v /somePath/FileToDelete > /somePath/filetoLog.log

【问题讨论】:

    标签: shell cron timestamp verbose


    【解决方案1】:

    一种方法是显式调用date

    0 06 * * *  (date && rm -v /somePath/FileToDelete) > /somePath/filetoLog.log
    

    【讨论】:

    • 我试过了,但日志文件只是说“已删除”。没有日期?
    • @miniHessel arg,忘记了括号,所以只有 rm 被重定向。 Mea culpa - 请参阅我编辑的答案。
    • 没有成功。仍然只是说删除。删除了'pathtoFile'
    • 现在开始工作了。不知道是不是跟缓存有关。谢谢!
    猜你喜欢
    • 2023-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-26
    • 2019-02-01
    • 1970-01-01
    • 2014-01-24
    • 1970-01-01
    相关资源
    最近更新 更多