检查脚本是否每5分钟运行一次

时间:2020-12-01 16:24:17

we have scheduled one script to run for every 5 mins.

我们已安排一个脚本每5分钟运行一次。

how we can check that whether the script is running for every 5 minutes in linux?

我们如何检查脚本是否在linux中每5分钟运行一次?

If anyone knows, please Reply..

如果有人知道,请回复..

Thanks in Advance.

提前致谢。

We have created the script. But we dont run that script. Our Support team will run this for every minutes. If they found any error, then they will update to us. How we can cofirm that they r running this script properly or not?

我们已经创建了脚本。但我们不运行该脚本。我们的支持团队将每分钟运行一次。如果他们发现任何错误,那么他们会更新给我们。我们如何确定他们是否正确运行此脚本?

4 个解决方案

#1


If you don't want to modify your script and you've scheduled it in cron, you could change your cron line to:

如果您不想修改脚本并且已在cron中安排它,则可以将cron行更改为:

*/5 * * * * /home/me/myscript.sh; date >> /tmp/mylog

And check /tmp/mylog - a new line should be added with the date and time every run.

并检查/ tmp / mylog - 每次运行时都应添加一个新行和日期和时间。

#2


Maybe by making the script log in a logfile with the timestamp, so you can verify if the timestamp is OK, something like:

也许通过使脚本登录带有时间戳的日志文件,以便您可以验证时间戳是否正常,例如:

date >>/tmp/myprocess.log

at the top of the script (or in the loop if that's how you're "running" it) then you can examine the log file to check.

在脚本的顶部(或在循环中,如果你正在“运行”它),那么你可以检查日志文件进行检查。

#3


Maybe you could just add a log with a timestamp in your script ? Then you could see if the script was effectively run every 5 min.

也许您可以在脚本中添加带时间戳的日志?然后你可以看到脚本是否每5分钟有效运行一次。

#4


Without changing the script?

不改变脚本?

atop is a process monitor package that can record history of programs being run, and as root will catch terminations as well. See http://www.atcomputing.nl/Tools/atop/whyatop.html

atop是一个进程监视器包,可以记录正在运行的程序的历史记录,并且root用户也可以捕获终止。请参阅http://www.atcomputing.nl/Tools/atop/whyatop.html

Also consider the process accounting tools http://www.faqs.org/docs/Linux-mini/Process-Accounting.html

还要考虑流程会计工具http://www.faqs.org/docs/Linux-mini/Process-Accounting.html

#1


If you don't want to modify your script and you've scheduled it in cron, you could change your cron line to:

如果您不想修改脚本并且已在cron中安排它,则可以将cron行更改为:

*/5 * * * * /home/me/myscript.sh; date >> /tmp/mylog

And check /tmp/mylog - a new line should be added with the date and time every run.

并检查/ tmp / mylog - 每次运行时都应添加一个新行和日期和时间。

#2


Maybe by making the script log in a logfile with the timestamp, so you can verify if the timestamp is OK, something like:

也许通过使脚本登录带有时间戳的日志文件,以便您可以验证时间戳是否正常,例如:

date >>/tmp/myprocess.log

at the top of the script (or in the loop if that's how you're "running" it) then you can examine the log file to check.

在脚本的顶部(或在循环中,如果你正在“运行”它),那么你可以检查日志文件进行检查。

#3


Maybe you could just add a log with a timestamp in your script ? Then you could see if the script was effectively run every 5 min.

也许您可以在脚本中添加带时间戳的日志?然后你可以看到脚本是否每5分钟有效运行一次。

#4


Without changing the script?

不改变脚本?

atop is a process monitor package that can record history of programs being run, and as root will catch terminations as well. See http://www.atcomputing.nl/Tools/atop/whyatop.html

atop是一个进程监视器包,可以记录正在运行的程序的历史记录,并且root用户也可以捕获终止。请参阅http://www.atcomputing.nl/Tools/atop/whyatop.html

Also consider the process accounting tools http://www.faqs.org/docs/Linux-mini/Process-Accounting.html

还要考虑流程会计工具http://www.faqs.org/docs/Linux-mini/Process-Accounting.html