發表文章

目前顯示的是 4月, 2017的文章

ssh 出現 error in libcrypto Connection closed 錯誤訊息

 最近公司的產品OS更換到Alma Linux,因此安裝了一台全新的Alma Linux機器,然後接下來要使用scp去別的主機搬移檔案的時候出現了下面的錯誤訊息 The authenticity of host '10.*.*.68 (10.*.*.68)' can't be established. RSA key fingerprint is SHA256:RKJMaNXf4Fw5I2rjsdiLr17MQn1LTyMurlb6hV2qo18. This key is not known by any other names Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '10.*.*.68' (RSA) to the list of known hosts. ssh_dispatch_run_fatal: Connection to 10.*.*.68 port 22: error in libcrypto Connection closed 解決方法是指定加密演算法 update-crypto-policies --set DEFAULT:SHA1

centos 6.x 安裝 node 之方法

Centos 6.x 已經算是較舊的系統,yum相關的資源表需要做些更新才能安裝較新版的node , 以下即為安裝的方式。 # yum install -y gcc-c++ make # curl -sL https://rpm.nodesource.com/setup_6.x | sudo -E bash - yum install nodejs 最後確認安裝版本 node -v npm -v

Linux -- shell script 取得unix timestamp 並且產出時間字串

假設有個需求,使用shell script 去執行某個特定的程式並且要輸入兩個數值--> 起始時間與結束時間,詳細的數值規格如下 1. 結束時間取目前的系統時間 2. 起始時間與結束時間相差6小時 3. 輸入時間格式為 yyyymmddhhmm 下面為針對此需求製作之shell script #!/bin/sh #get the end time from system unix timestamp etime=$(date +'%s') #get the start time which was difference of 6 hours with end time . let stime=etime-43200 # 6 hours in secs #print time for check echo $stime echo $etime # turn unix timestamp to date time string fetime=$(date -d @$etime +'%Y%m%d%H%M') fstime=$(date -d @$stime +'%Y%m%d%H%M') python xxxxxx.py "$fstime, $fetime"

Python -- 將unix timestamp 轉為字串時間之作法

當取得或處理過的unix timestamp 要轉成字串形式的資料時有下面兩個選擇 1. 依據local time 做字串轉換 from datetime import datetime import tzlocal # $ pip install tzlocal unix_timestamp = 1491372600 local_timezone = tzlocal.get_localzone() local_time = datetime.fromtimestamp(unix_timestamp, local_timezone) print(local_time.strftime("%Y-%m-%d %H:%M:%S.%f%z (%Z)")) 2. 只是單純轉換,依舊是UTC 時區 from datetime import datetime utc_time = datetime.utcfromtimestamp(unix_timestamp) print(utc_time.strftime("%Y-%m-%d %H:%M:%S.%f+00:00")) 最後附上 時常用來做驗證的線上小工具 http://www.onlineconversion.com/unix_time.htm