From: Ben Bacarisse on
Kun Liu <royliuk(a)hotmail.com> writes:

> I need to write a shell script (or perl script if possible) to do the
> following:
>
> Every day starting from 10:00am, the shell script should periodically
> check if an input file has been created by another process. If the
> file is not created yet, nothing happens. As long as the file has
> been created, the shell script will launch another program to analyze
> the file and then exits. If at 5:00pm, the input file is still
> missing, the shell script stops monitoring and exits.
>
> This process repeats on a daily basis.
>
> I was thinking about using "cron" to do this. But it seems that 'cron"
> does not allow me to specify the start and end time that the process
> should monitor the input file.

It may be more helpful than you think:

*/5 10-17 * * * my-program

runs my-program every 5 minutes between 10am and 5pm. If you have an
old cron that does not understand / for a step value and - for a range
you will have to write it out:

0,5,10,15,20,25,30,35,40,45,50,55 10,11,12,13,14,15,16,17 * * * ...

If you literally want cron to start and then stop the program, you
need two entries: one that starts it at 10 and another that stops it
at 5pm. A common mechanism is for the script to put its process ID
into a file like /var/run/my-program.pid so that it can be killed with
a signal.

--
Ben.