Linux运行有时间限制的命令—timeout命令


当我们想让一个定时的crontab任务运行运行一段时间后,自动终止? 有两种方案:

一、启动一个进程任务,然后在启动一个杀死进程任务

二、使用linux中的timeout命令

示例:执行crontab -e 进入定时任务,添加如下命令

30 9 * * * timeout -s SIGKILL 12h /home/pirate/programs/hadoop/bin/hdfs balancer -threshold 10  > ~/balancer-stdout.log 2>~/balancer-stderr.log & 
32 9 * * * /home/pirate/programs/hadoop/bin/hdfs dfsadmin -setBalancerBandwidth 304857600

参考:

Linux运行有时间限制的命令—timeout命令


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM