4

當程式沒問題時就會吃掉輸出的 chronic

 2 years ago
source link: https://blog.gslin.org/archives/2018/06/21/8375/%e7%95%b6%e7%a8%8b%e5%bc%8f%e6%b2%92%e5%95%8f%e9%a1%8c%e6%99%82%e5%b0%b1%e6%9c%83%e5%90%83%e6%8e%89%e8%bc%b8%e5%87%ba%e7%9a%84-chronic/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

當程式沒問題時就會吃掉輸出的 chronic

跑 cron job 的時候,希望程式有問題的時候通知管理者 (或是執行者),這個可以透過 moreutils 內的 chronic 來達成:

chronic - runs a command quietly unless it fails

chronic 會將 stdout 與 stderr 的輸出結果暫存起來,如果程式正常結束 (exit 0) 就不管他,但如果有問題的時候就會 output 出來 (exit 不是 0,或是 crash),而 cron 在收到 stdout/stderr 有東西時,會寄信給管理者或是執行者,這剛好就是我們要的行為。

算是很好用的指令,沒事你不會想管他輸出什麼啊... XD

Related

OuiOuiOui 的 tag spam

當初利用 ouiouioui 成立「[企畫] 共筆書籤」的時候 quawn 就有在思考 Spam 的問題: 可能會有很大一部份的朋友對於這個想法會存疑,我了解,因為就連我也掙扎了很久。如果有人惡搞?如果有人狂打自家網站的廣告?如果ouiouioui的標籤被SPAM盯上?這些考慮都曾經阻礙了我心中想法的實踐進度,不過,小弟覺得儘管這個計劃有一天失敗了、或是事實證明根本不可行,那至少我們試圖證明過,就像大多數的科學實驗一樣,尤其,特別在這個實驗並沒有明顯的成本時。 當時擔心的事情,很不幸的,發生了。 可以看到 某個人 幾乎自己每寫一篇文章就 submit 到 del.icio.us 的 ouiouioui:http://del.icio.us/pojenhuang/ouiouioui。 除了 ouiouioui 被 spam 外,hkblogger 也被 spam:http://del.icio.us/pojenhuang/hkblogger。 說實話,我覺得這位先生寫的文章跟第四台賣藥的節目差不多 - 自吹自擂,努力推銷。 Update:我寫完這篇以後才發現 豬小草 早在六月的時候就已經在「[企劃] 共筆書籤」這篇 comment 的地方幹剿過了: 那個「上班族投資理財」每次都利用共筆書籤幫自己的文章打廣告,這樣不太好吧。如果你真的寫的好,自然有人會摘阿,何必要自己在那邊強力推薦呢?

August 14, 2005

In "Blog"

168.95.1.1 與 168.95.192.1 對 CloudFront 的差異

tl;dr 版本:目前先用 PPPoE 發出來的 DNS resolver 設定,如果要自己設定的話,用 168.95.192.1 (主) + 168.95.1.1 (次) 然後關掉 round-robin 模式。 剛剛看 SmokePing 時發現的奇怪現象,同樣都是在 HiNet 下面的機器與 DNS resolver,但 CloudFront 會給出不同的機房提供服務。 講的更仔細的是,168.95.192.1 這組會給出 tpe 系列的機房,所以 latency 會比較低,但如果你用的是 168.95.1.1 的話,就會到處丟,包括日本的 nrt 系列,與香港的 hkg 系列。 這邊拿 d36cz9buwru1tt.cloudfront.net 這組網域觀察,這是 AWS 官網用的資源,從官網的 html 原始碼裡面可以看到。 以第四台網路上面的機器上面來看 (北都,我分配到的線路是走台灣智慧光網的線路),可以看到這邊 latency 會飄:「d36cz9buwru1tt.cloudfront.net (CloudFront)」。 看了一下 DNS…

February 20, 2022

In "AWS"

桌機的 Ubuntu 12.04 升級到 14.04

拖了好久,總算利用連假的時間 (而且在台灣!) 把桌機的 Ubuntu 12.04 (Precise) 升級到 14.04 (Trusty)。整個升級的過程果然充滿了地雷... XD 這邊當作雜記記錄下來,希望對之後的人升級有幫助。其中比較重要的前提是,我是用 Unity,所以升級的流程大致照著官方的指示做就可以了,對於使用 GNOME 的人,需要再多研究看看? 升級前的注意事項: 假設當初有裝很多 UNSUPPORTED 的 repository (這邊是指官方的 *.archive.ubuntu.com 裡有一些沒有被官方支援的項目,像是 universe 與 multiverse),要記得到 /etc/apt/sources.list 裡暫時註解掉。 跑 do-release-upgrade 時的語系要用英語系 (C、en_US 之類的,像是 env LANG=C LANGUAGE=C LC_ALL=C do-release-upgrade 這樣執行),不然會造成 Python 的錯誤訊息 (decode error,因為是用 ascii 去解),原因是 /etc/apt/sources.list.d/ 下面在替換 precise -> trusty 時會增加註解,而這個註解在…

January 5, 2015

In "Computer"

a611ee8db44c8d03a20edf0bf5a71d80?s=49&d=identicon&r=gAuthor Gea-Suan LinPosted on June 21, 2018Categories Computer, Murmuring, SoftwareTags chronic, cron, mail, moreutils, stderr, stdout

One thought on “當程式沒問題時就會吃掉輸出的 chronic”

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment *

Name *

Email *

Website

Notify me of follow-up comments by email.

Notify me of new posts by email.

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Learn More)

Post navigation


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK