3 ms·
Recently I found myself wanting to stop a program after a certain timeout. I found myself thinking "sure there's a UNIX program to do this in shell?" There is.
by jerf 7y ago
Recently I found myself wanting to stop a program after a certain timeout. I found myself thinking "sure there's a UNIX program to do this in shell?" There is. And it's called... brace yourself... "timeout".
20+ years in UNIX, never encountered it. Part of GNU coreutils.
- saagarjha 7y agoIt’s unfortunately not part of POSIX, which means that BusyBox can’t get the options right or even stay consistently wrong :(
- mekster 7y agoSometimes good to use for cron jobs so that the previous one won't keep running on top of the current run. You should debug for it to not happen though but probably better than seeing your system choke with dozens of instances even slowing the jobs more. There's also "run-one" that allows you to control which job should survive instead of just killing the old one. http://manpages.ubuntu.com/manpages/trusty/man1/run-one.1.html http://manpages.ubuntu.com/manpages/trusty/man1/run-one.1.ht...
- majewsky 7y agoIf you're using systemd timers, you get this behavior for free because those timers only activate service units. If the service is already active, nothing happens. (Of course, this can be surprising in a different way when you expect a new job to start, but it does not because a previous one is still lingering. Not saying it's better or worse, just pointing out for those who don't know.)