Running a shell command for a specific period of time

der.hans PLUGd at LuftHans.com
Thu Oct 27 18:06:50 MST 2005


Am 26. Oct, 2005 schwätzte Erik Bixby so:

> I was wondering if anyone knew a way to allow a shell command to run for a
> specific period of time. In this particular case, I want tcpdump to run for
> 23 hours, 59 minutes, 59 seconds. I couldn't find anything in the tcpdump
> man page that gave me the impression that tcpdump itself has that
> functionality. And, I couldn't find anything in a quick google search. I
> also thought it was an interesting scripting trick that I don't know, and
> thought I'd ask you nice folks...

I just ran into timeout.

Description: Run a command with a time limit.
  timeout executes a command and imposes an elapsed time limit. When the
  time limit is reached, timeout sends a predefined signal to the target
  process.

I like Lynn's solution.

You might also just have a cronjob that kills and execs tcpdump at the
right point.

Presuming the reason you're doing this is to split the log files you might
want to investigate whether or not you can blip tcpdump to change logfiles
w/o shutting down.

ciao,

der.hans
-- 
#  https://www.LuftHans.com/
#  "So the environment is not a luxury ... It is an economically important
#  insurance policy whose wisdom we ignore at our peril."
#  -- Klaus Toepfer, U.N. environment agency Executive Director


More information about the PLUG-discuss mailing list