6月 042021
 

如果让服务本身支持定时关闭,理论上非常可行,但是所有想定时关闭的服务都去实现以下这个逻辑是不是不太好?对于一个已经很成熟的(甚至没有源码的)服务想实现这个功能又该怎么办呢?

根据Linux的思想,一个程序应该只做一件事,并非功能越多越好,把自己该做的事做好就行了。

Linux上有一个非常好的命令: timeout 。只做了一件事,可以实现一个程序在一段时间后结束,如:

 

sleep 想睡10s; 但是timeout 保证让他2s就死掉

 Posted by at 上午 10:39

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

(required)

(required)

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据