# R 統計軟體語言 ###### tags: `R` Created: 2015-10-15 By 蓉爸 Revised: 2015-10-15 ## 線上免費教學資源 * R 軟體入門(台北醫學大學 沈彥廷 副統計分析師) http://biostat.tmu.edu.tw/oldFile/enews/ep_download/14rb.pdf * R Software (R軟體教學/R語言程式設計) http://www.hmwu.idv.tw/index.php/r-software * R 教學 (By G. T. Wang) https://blog.gtwang.org/programming/r/ ## 工具程式 > 跟企業合作時,經常需要在 Linux 伺服器定時跑一個或多個有使用 foreach 平行運算的 R 程式。 > > 久了之後,就會在某些 Linux 伺服器上發現,可能是因為記憶體或其他因素,某些 R 程式在開始 doParallel 分支出各 CPU 核心時,偶而會卡住不動。此時就需要把原來的 process 砍掉,重新執行。 > > 以下是我寫的 Linux/Unix shell script 檢查程式,可以放到 cron 中定時執行,若有某個 R 程式執行時間超過 2 小時 (3600x2=7200 秒),就把 process 砍掉。有需要的人可以參考一下 ```shell= #!/bin/bash ## ps -eo pid,comm,lstart,etimes,time,args|grep R|awk '{print $1 "%" $8}'|grep -v PID ## 8872%16759 ## 8888%16759 ## 8890%16759 ## 19960%0 XDATE=$(date +"%Y-%m-%d %T") echo "$XDATE:" ps -eo pid,comm,lstart,etimes,time,args|awk '{print $1 "%" $8}'|grep -v PID | while read output; do xpid=$(echo $output | cut -d'%' -f1 ) xtime=$(echo $output | cut -d'%' -f2 ) if [ $xtime -ge 3600 ]; then echo "Pid: $xpid" echo "Elapse time: $xtime seconds" kill -9 $xpid echo "Pid $xpid killed !" fi done ``` Ref: https://www.facebook.com/groups/1210634969026548/permalink/2498267563596609/
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up