运行命令每一秒 [英] Run command every second

查看:104
本文介绍了运行命令每一秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一些图片下载并为其分配的庆典。我已经和我需要什么:

I want to write some image downloader and assign it on bash. What I have and what I need:

我有:


  1. 命令,工作正常(类似的wget
    http://mywebcam.com/image.jpg -O /var/cam/Image.jpg

  2. 根权

  1. Command, which works fine (something like wget http://mywebcam.com/image.jpg -O /var/cam/Image.jpg)
  2. Root rights

我的服务器和我的摄像头之间的快速上网线

Fast Internet line between my server and my webcam

我需要的:

从相机下载图像每秒*(睡眠1?)*和localY重写它的(我的命令,把它做好)
在一次运行此脚本,不用担心重启的(我想我需要创建使用bash命令文件并运行它一次+关于重启这个文件中设置的crontab的工作,对不对?)

Download image from camera every second*(sleep 1?)* and rewrite it localy (my command do it well) Run this script at once and don't worry about restart (I think I need to create file with bash commands and run it once + set crontab work "on reboot" to this file, right?)

也许有一个人谁知道我应该怎么办?

Maybe there's someone who knows what should I to do?

推荐答案

如果你想在同一秒的间隔(一个命令的结束和下一个的开始,这是不一样的之间的一个跑秒的命令运行每秒),只是做:

If you want to run a command at one second intervals (one second between the end of one command and the beginning of the next, which is not the same as running every second), just do:


while sleep 1; do cmd; done

如果您希望开始在重新启动,该方法将取决于您的系统。

If you want that to start on reboot, the method will depend on your system.

这篇关于运行命令每一秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆