运行命令每一秒 [英] Run command every second
问题描述
我想写一些图片下载并为其分配的庆典。我已经和我需要什么:
I want to write some image downloader and assign it on bash. What I have and what I need:
我有:
- 命令,工作正常(类似
的wget
)
http://mywebcam.com/image.jpg -O /var/cam/Image.jpg -
根权
- Command, which works fine (something like
wget http://mywebcam.com/image.jpg -O /var/cam/Image.jpg
) 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屋!