计算一个cron的运行时间
问题描述:
我有一个工作正常的cron,但我想计算cron的执行时间。计算一个cron的运行时间
我的cron看起来像
0 */3 * * * root cd mydir && python myscript >> /var/log/mylog 2>&1 && curl https://nosnch.in/1837838u7184 &> /dev/null
我已经试过这没有运气。我想发送的时间https://nosnch.in/blablabla
0 */3 * * * root m=`time(cd mydir && python myscript >> /var/log/mylog &> /dev/null) 2>&1` && curl -d "m=$m" https://nosnch.in/1837838u7184
有什么建议吗?
答
壳内置的cd
总是有一个非常微不足道的时间。所以只需测量你的python脚本的时间。
0 */3 * * * root cd mydir && time python myscript >> /var/log/mylog 2>&1 && curl https://nosnch.in/1837838u7184 &> /dev/null
或者,做一些shell脚本$HOME/bin/myweirdscript
(同时包含python myscript
&的curl https://nosnch.in/1837838u7184
命令)和time
,所以你crontab
进入现在变成:
0 */3 * * * root time $HOME/bin/myweirdscript
答
我要发送的时间到https://nosnch.in/blablabla
没有表格发布在https://nosnch.in/blablabla或https://nosnch.in/1837838u7184。阅读cURL Manual部分POST (HTTP)
。
不是我正在寻找的解决方案。不管怎么说,还是要谢谢你。 – Simar
我想将时间发送到网址。 – Simar
这应该进入问题 –