惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Spread Privacy
Spread Privacy
S
Schneier on Security
G
GRAHAM CLULEY
AWS News Blog
AWS News Blog
Cisco Talos Blog
Cisco Talos Blog
The Hacker News
The Hacker News
T
The Exploit Database - CXSecurity.com
P
Proofpoint News Feed
L
LINUX DO - 热门话题
C
CXSECURITY Database RSS Feed - CXSecurity.com
Security Latest
Security Latest
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Google DeepMind News
Google DeepMind News
H
Hacker News: Front Page
PCI Perspectives
PCI Perspectives
T
Tenable Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
N
Netflix TechBlog - Medium
Application and Cybersecurity Blog
Application and Cybersecurity Blog
腾讯CDC
A
Arctic Wolf
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Project Zero
Project Zero
NISL@THU
NISL@THU
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
V
Vulnerabilities – Threatpost
Cyberwarzone
Cyberwarzone
I
Intezer
Apple Machine Learning Research
Apple Machine Learning Research
T
Threat Research - Cisco Blogs
爱范儿
爱范儿
Webroot Blog
Webroot Blog
Forbes - Security
Forbes - Security
The Cloudflare Blog
T
Tailwind CSS Blog
C
CERT Recently Published Vulnerability Notes
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
大猫的无限游戏
大猫的无限游戏
Microsoft Azure Blog
Microsoft Azure Blog
Know Your Adversary
Know Your Adversary
云风的 BLOG
云风的 BLOG
B
Blog
The Register - Security
The Register - Security
T
Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
V2EX - 技术
V2EX - 技术
P
Privacy & Cybersecurity Law Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org

博客园 - Jeff

4个月 C++ 有限状态机 POJ1019 POJ1035 POJ1007 POJ1005 ONLINE_JUDGE 怪异的grep结果 URL2FILE C primer笔记 Vxworks增加system call C语言常用宏定义技巧 分苹果 Socket 为什么选择SMP而不是AMP RTP memory in Vxworks Windriver的项目类型 RTP affinity Symmetric multiprocessing (SMP)
Linux shell定时器
Jeff · 2011-12-26 · via 博客园 - Jeff

2011-12-26 16:02  Jeff  阅读(11757)  评论()    收藏  举报

网上找了个例子,简单实用如下. 可以有一个后台进程,在timer超时采取一些操作.

 
#!/bin/ksh
#Delaytime=0
AlarmHandler()
{
echo "Get SIGALAM"
KillSubProcs
exit 14
}
KillSubProcs()
{
#kill cbm
echo "it's time out,kill cbm here"
if [ $? -eq 0 ];then
echo "Sub-processes killed."
fi
}

SetTimer()
{
Delaytime=$1
echo $Delaytime
if [ $Delaytime  -ne 0 ];then
sleep $Delaytime  && kill -s 14 $$ &
#CHPROCIDS="$CHPROCIDS $!"
TIMERPROC=$!
fi
}
UnsetTimer()
{
echo "Start to unset timer"
kill $TIMERPROC
}

trap AlarmHandler 14
SetTimer 30
#CHPROCIDS="$CHPROCIDS $!"
#wait $!
sleep 40
UnsetTimer
echo "ALL Done."
exit 0