加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – Crontab:有开始和结束时间的日志吗?

发布时间:2020-12-14 02:38:54 所属栏目:Linux 来源:网络整理
导读:我的 linux服务器上有很多crontask用于我们的应用程序.但我没有找到任何方法知道任务何时结束,以及它运行了多长时间. 我必须添加一个类似软时间的命令来记录这个吗?有没有办法配置cron来做到这一点? 我在/etc/cron.daily中有一个脚本需要花费太多时间,但我
我的 linux服务器上有很多crontask用于我们的应用程序.但我没有找到任何方法知道任务何时结束,以及它运行了多长时间.
我必须添加一个类似软时间的命令来记录这个吗?有没有办法配置cron来做到这一点?
我在/etc/cron.daily中有一个脚本需要花费太多时间,但我无法确定哪一个!

问候,
塞德里克

解决方法

男子cron

你应该看到类似的东西

-L loglevel
               Sets the loglevel for cron. The standard logging level (1) will
               log  the start of all the cron jobs. A higher loglevel (2) will
               cause cron to log also the end of all cronjobs,which  can  be
               useful  to  audit  the  behaviour of tasks run by cron. Logging
               will be disabled if the loglevel is set to zero (0).

要使用该选项,您可以查看/ etc / default / cron

至少在Debian中它有这样的评论:

# Extra options for cron,see cron(8)
# For example,set a higher log level to audit cron's work
# EXTRA_OPTS="-L 2"

在更改配置文件后,您需要重新启动Cron:

/etc/init.d/cron restart

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读