in reply to Kill a script at a certain time

You could kill the script with killall scriptname in your crontab (or in a shell script).

Or you could try something like this in your script (assuming it is a perl script):

my $top_at_hour = 4; while ((localtime(time))[2] < $stop_at_hour) { # do some specific stuff here.. } exit;
Ps: I never remember if 4pm == 04.00 hr or 16.00 hr.
-- Joost downtime n. The period during which a system is error-free and immune from user input.

Replies are listed 'Best First'.
Re: Re: Kill a script at a certain time
by jasonk (Parson) on Feb 17, 2003 at 18:13 UTC

    Be very careful about suggesting 'killall' as a solution to anything unless you are sure what platform they are running on. On linux killall means 'kill all the processes with this name', on Solaris killall means 'kill every process on the machine in preparation for shutdown'. Obviously if you run it on Solaris and want the Linux behavior, you will be disappointed. :)

    P.S. 4pm is 1600 hours

      Thanks for the tip. I'm glad I never used killall in the scripts I wrote for solaris. :-)
      -- Joost downtime n. The period during which a system is error-free and immune from user input.