zoukankan      html  css  js  c++  java
  • [原创] 使用rpi + crontab + git 定时向bitbucket 推送 照片

    #前提条件,你得有一个bitbucket的帐户

    1.定时启动脚本代码

    使用的是crontab 

     Cronfile 内容如下:

    此文件的意思是,每隔10分钟,就运行一次 /home/pi/Rpi_upload.sh 脚本 

    */10 * * * * /home/pi/Rpi_upload.sh    

    2. 添加到定时任务当中去

        

    pi@raspberrypi$ crontab cronfile  #加载之前写的cronfile文件

    查看有没有添加到定时任务 

      

    pi@raspberrypi$ crontab -l 
    
    显示内容如下:
    
    */10 * * * * /home/pi/Rpi_upload.sh 

    3. 上传到 bitbucket的脚本如下:

    # ! /bin/bash
    #create by sndnvaps 
    #date : 2015-03-30 
    # bsd license 
    
    random=$(date +%s%N)
    
    jpegname=$random.jpg
    
    #Takeshot use webcam
    if [ ! -f $jpegname ];
          then
    
             echo $jpegname
             filename=$jpegname
             sudo fswebcam -d /dev/video1 -r 1280x720 --bottom-banner --title "RaspberryPi C270 @sndnvaps" /home/pi/$filename
    
          else
              echo "file $jpegname is exists!"
    fi
    
    
    
    #upload the pic to bitbucket.org
    
     if [  ! -d /opt/takeshot_rpi ]
            then
                mkdir -p /opt/takeshot_rpi
                cd /opt/takeshot_rpi
                git init
                git remote add origin git@bitbucket.org:sndnvaps/rpi_upload_pic.git
             else
                filename=$jpegname
                echo $filename
                sudo   cp /home/pi/$filename /opt/takeshot_rpi/
                cd /opt/takeshot_rpi
                git add *
                git commit -s -m "update $jpegname"
                git push origin master:master
                echo "upload $jpegname to bitbucket.org done."
     fi
  • 相关阅读:
    Maven 环境的配置
    zTree的简单例子
    plsql免安装客户端的配置
    HDU 1232 畅通工程
    HDU 5698 瞬间移动
    Codeforces 1015E1 Stars Drawing (Easy Edition)
    Codeforces 784B Santa Claus and Keyboard Check
    Codeforces 500C New Year Book Reading
    NSarray 赋值 拷贝 等问题记录
    UINavigationController 操作记录
  • 原文地址:https://www.cnblogs.com/sn-dnv-aps/p/4378936.html
Copyright © 2011-2022 走看看