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
  • 相关阅读:
    二分图最大匹配(匈牙利算法) POJ 3041 Asteroids
    贪心 FZU 2013 A short problem
    数学 FZU 2074 Number of methods
    莫队算法/二分查找 FZU 2072 Count
    畅通工程 HDU
    Minimum Inversion Number~hdu 1394
    I Hate It HDU
    A Simple Problem with Integers~POJ
    敌兵布阵
    Coins HDU
  • 原文地址:https://www.cnblogs.com/sn-dnv-aps/p/4378936.html
Copyright © 2011-2022 走看看