我正在给一个覆盆子相机编程
因此,我需要在每天上午9点执行一个sh脚本,但随后,该脚本必须每10秒运行一次。
比如它在早上6点开始拍照,每隔10秒拍照一次,直到我自动重启系统,这样它就会停止命令。
00 09 * * 1 watch -n 10 sh /home/pi/timelapse/process1.sh
00 09 * * 2 watch -n 10 sh /home/pi/timelapse/process1.sh
00 09 * * 3 watch -n 10 sh /home/pi/timelapse/process1.sh
00 09 * * 4 watch -n 10 sh /home/pi/timelapse/process1.sh
00 09 * * 5 watch -n 10 sh /home/pi/timelapse/process1.sh
00 17 * * 1 sudo reboot
00 17 * * 2 sudo reboot
00 17 * * 3 sudo reboot
00 17 * * 4 sudo reboot
00 17 * * 5 sudo reboot
30 17 * * 1 sh /home/pi/timelapse/newimage/video.sh
30 17 * * 2 sh /home/pi/timelapse/newimage/video.sh
30 17 * * 3 sh /home/pi/timelapse/newimage/video.sh
30 17 * * 4 sh /home/pi/timelapse/newimage/video.sh
30 17 * * 5 sh /home/pi/timelapse/newimage/video.shreboot crontab必须在下午5点停止第一个命令,所以我不需要编程让它停止。然后,它会用命令中的所有照片制作视频。
我尝试使用crontab、watch和sleep,但crontab甚至在sh脚本中都不运行它们。
建议在文件夹中创建图像,但不是这样做。我把代码放在这里。当我手动执行它时,它可以工作。
raspistill -w 1920 -h 1080 -o /home/pi/timelapse/images/imageBTW.jpg DATE=$(date +"%Y-%m-%d_%H%M%S") for file in "/home/pi/timelapse/images/imageBTW.jpg" ; do convert "$file" \ -pointsize 72 -fill white -annotate +100+100 \ %[exif:DateTimeOriginal] /home/pi/timelapse/newimage/$DATE.jpg done rm /home/pi/timelapse/images/imageBTW.jpg发布于 2020-03-09 18:36:16
试着读一下这个:man 5 crontab
在那里你会找到信息,那就是cron只以分钟精度工作。
但是您可以将以下内容写入crontab中
0 9 * * 1-5 watch -n 10 sh -c 'while /home/pi/timelapse/process1.sh; do sleep 10; done'顺便说一句,你想刺探谁?
https://stackoverflow.com/questions/60597501
复制相似问题