linux - Exit perl script automatically every 2 hours -
i have perl scipt need end every 2 hours on linux machine. going separate script , add on cron.d accomplish this, wanted easier way. has graceful exit because after doing ctrl+c, writes log file , killing won't write file.
you can set alarm @ beginning of script, , provide handler it:
alarm 60 * 60 * 2; local $sig{alrm} = sub { warn "time over!\n"; # logging here... exit };
the question how restart script again.
Comments
Post a Comment