sean finney on 23 Sep 2009 00:16:12 -0700

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] correct way to do this in bash

hi mag,

On Tue, Sep 22, 2009 at 07:35:06PM -0400, Mag Gam wrote:
> oh wow, SIGUSR1 sounds very complicated.

i suggest you give that a second consideration.  i don't think that it's
as complicated as you think it is :)

~ ~ ~ ~

# catch USR1 to do some ad-hoc log rotation
trap newlog SIGUSR1

  ts="$(date +%Y%m%d.%H%M%S)"
  # redirect all stdout/stderr here
  exec >"data-${ts}.log" 2>"data-${ts}.err"

# first time redirection setup

~ ~ ~ ~

and then just schedule a kill/pkill in your crontab (throwing your pid
into a seperate file at startup might be helpful for that as well).


Attachment: signature.asc
Description: Digital signature

Philadelphia Linux Users Group         --
Announcements -
General Discussion  --