zoukankan      html  css  js  c++  java
  • Shell再学习 规格严格

    1、http://blog.csdn.net/chinalinuxzend/article/details/2403613

    最近项目又要求写shell脚本完成相应升级工作,无奈,这工作又落在我脑袋上,于是我还得在学习学习。

    添加一段测试时间戳的简单脚本:


    #Ghetto auto SCP script Bryan Encina 10-16-2003  

    #Assumptions:    passwordless SCP has been setup via generation of private/public 
    #        keypair and insertion of pub key to webhost user's  
    #        .ssh/authorized_keys file 
    #Intended Use:  uploading webcam image from linux server to another webhost 
    #        that does not support FTP (only SCP), probably of no use to anyone else 
    #Usage:        make an entry in your crontab to run as the user who's setup for passwordless scp 
    #        to run this script with the path to your webcam img as a  
    #        command line arg         

    #user settings edit the vars below 
    checkduration=300          #if current - timestamp is less than this we have a new file default to 5 minutes 
    remoteuser=myremoteuser    #user at remote host 
    mydomain=mydomain.com    #the domain/ip of your remote host 
    destpath=yourfile        #the path to your remote file 

    #do not edit below unless you know what you're doing, but if you did you  
    #wouldn't be using this and you'd be writing your own wouldn't you? 
    localfile=$1 

    cur_timestamp=`date +%s` 
    my_stat=`stat -t $localfile 2>/dev/null` 
    read name size blocks unk uid gid dev inode links unk2 unk3 last_access last_mod last_change ioblock << ENDHERE 
        $(echo $my_stat) 
    ENDHERE 

    if [ $last_mod ] 
    then 
        time_diff=`expr e$cur_timestamp - $last_mod` 
        if [ $time_diff -lt $checkduration ] 
        then     
            #echo This is a recent file 
            scp $localfile $remoteuser@$mydomain:$destpath 
        fi 
    fi  
  • 相关阅读:
    深入理解Nginx及使用Nginx实现负载均衡
    Linux内存管理之伙伴系统之伙伴系统概述
    TCP 协议如何解决粘包、半包问题
    Linux CPU亲缘性详解
    单实例
    关联容器和无序关联容器的区别
    基于范围的for循环
    vector讲一个容器的内容拷贝到另一个容器,容器的区间删除
    win32窗口添加按钮及按钮消息相应,动态显示时间
    判断是不是纯数字字符串
  • 原文地址:https://www.cnblogs.com/diyunpeng/p/2446445.html
Copyright © 2011-2022 走看看