RICH-ATONE

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命令

posted on 2021-10-15 18:18  RICH-ATONE  阅读(1266)  评论(0编辑  收藏  举报

导航