开发者社区 问答 正文

linux定时任务如何每隔0.5秒执行一次呢?

求一个例子!!!linux定时任务如何每隔0.5秒执行一次呢?

展开
收起
a123456678 2016-06-20 16:32:33 3619 分享 版权
1 条回答
写回答
取消 提交回答
  • 由于 crontab 最小单位是分钟,只能自己写程序执行了。给个 shell + python 的例子:

    while true ; do ./your-script & ; python -c "import time;time.sleep(0.5)"; done
    或者 python + shell:

    import time
    from subprocess import call
    while(True):

    call(["./your-script"])
    time.sleep(0.5)

    没有 linux 所以没有亲测,大概就是这么个思路

    2019-07-17 19:44:20
    赞同 展开评论
问答分类:
问答地址: