From: Pankaj on
Greetings,

We have a process in place where we need to manually check multiple
tasks at certain period of time in a day.

Eg:

Task 1 At 3:00 PM
Task 2 At 4:00 PM
Task 2 At 5:00 PM
Task 3 At 6:00 PM

We need to automate this as it is currently being done manually. I
need to come up with an approach as to keep following points in mind.

1) These tasks are repetitive in nature. Meaning, the Task 1 needs to
be checked multiple times in day
2) These Tasks can be updated/deleted/added. So if we have 2 tasks
that need to be checked at 3:00 PM, tomorrow there can be only 1 or 3
tasks in this time period.

Earlier I thought I can directly go ahead with coding these for there
respective time period. But there are many such task and their
maintenance will become difficult if they keep on getting updated/
added or deleted.

Can someone please suggest me an approach here which might need less
manual intervention later?

I am currently using Sun Solaris 5.8

TIA
From: Icarus Sparry on
On Mon, 11 Jan 2010 08:33:23 -0800, Pankaj wrote:

> Greetings,
>
> We have a process in place where we need to manually check multiple
> tasks at certain period of time in a day.
>
> Eg:
>
> Task 1 At 3:00 PM
> Task 2 At 4:00 PM
> Task 2 At 5:00 PM
> Task 3 At 6:00 PM
>
> We need to automate this as it is currently being done manually. I need
> to come up with an approach as to keep following points in mind.
>
> 1) These tasks are repetitive in nature. Meaning, the Task 1 needs to be
> checked multiple times in day
> 2) These Tasks can be updated/deleted/added. So if we have 2 tasks that
> need to be checked at 3:00 PM, tomorrow there can be only 1 or 3 tasks
> in this time period.
>
> Earlier I thought I can directly go ahead with coding these for there
> respective time period. But there are many such task and their
> maintenance will become difficult if they keep on getting updated/ added
> or deleted.
>
> Can someone please suggest me an approach here which might need less
> manual intervention later?
>
> I am currently using Sun Solaris 5.8
>
> TIA

One approach might be to do the following, (based roughly on the way the
systems boots using scripts in /etc/rc?.d).

Use cron to fire off a job every hour. This job would look something like

#!/bin/sh

cd /some/where
hour=$(date +%H)
if [ -d "$hour" ]
then
cd "$hour"
for i in *
do
"$i"
done
else
#echo "nothing to be done in this hour ($hour)"
fi

Then create shell scripts for each of your tasks, and then link then into
the directories /some/where/00, /some/where/16 etc. to change from two
tasks at 3pm to 3 tasks, add another file in the /some/where/15
directory. To remove a task just remove the file.
From: Pankaj on
On Jan 11, 11:50 am, Icarus Sparry <use...(a)icarus.freeuk.com> wrote:
> On Mon, 11 Jan 2010 08:33:23 -0800, Pankaj wrote:
> > Greetings,
>
> > We have a process in place where we need to manually check multiple
> > tasks at certain period of time in a day.
>
> > Eg:
>
> > Task 1             At 3:00 PM
> > Task 2             At 4:00 PM
> > Task 2             At 5:00 PM
> > Task 3             At 6:00 PM
>
> > We need to automate this as it is currently being done manually.  I need
> > to come up with an approach as to keep following points in mind.
>
> > 1) These tasks are repetitive in nature. Meaning, the Task 1 needs to be
> > checked multiple times in  day
> > 2) These Tasks can be updated/deleted/added. So if we have 2 tasks that
> > need to be checked at 3:00 PM, tomorrow there can be only 1 or 3 tasks
> > in this time period.
>
> > Earlier I thought I can directly go ahead with coding these for there
> > respective time period. But there are many such task and their
> > maintenance will become difficult if they keep on getting updated/ added
> > or deleted.
>
> > Can someone please suggest me an approach here which might need less
> > manual intervention later?
>
> > I am currently using Sun Solaris 5.8
>
> > TIA
>
> One approach might be to do the following, (based roughly on the way the
> systems boots using scripts in /etc/rc?.d).
>
> Use cron to fire off a job every hour. This job would look something like
>
> #!/bin/sh
>
> cd /some/where
> hour=$(date +%H)
> if [ -d "$hour" ]
> then
>         cd "$hour"
>         for i in *
>         do
>                 "$i"
>         done
> else
>         #echo "nothing to be done in this hour ($hour)"
> fi
>
> Then create shell scripts for each of your tasks, and then link then into
> the directories /some/where/00, /some/where/16 etc. to change from two
> tasks at 3pm to 3 tasks, add another file in the /some/where/15
> directory. To remove a task just remove the file.- Hide quoted text -
>
> - Show quoted text -

Thanks Icarus. I was also thinking on following approach

1) Have a separate file like below

Parent script

3 AM
-----------------------------------------------
JobTask1
JobTask2
JobTask3
------------------------------------------------

4AM
------------------------------------------------
JobTask3
JobTask4
JobTask5
------------------------------------------------

The idea is to come up with a separate script that gets called based
on different time period and in turn calls the above parent script and
respective section gets executed. Is there a way that when its 3 AM,
only 3 AM section should be executed and rest should be left
untouched.

We are currently using autosys feature in unix to schedule tasks.

TIA
From: OldSchool on
On Jan 11, 12:30 pm, Pankaj <harpreet.n...(a)gmail.com> wrote:
......

> The idea is to come up with a separate script that gets called based
> on different time period and in turn calls the above parent script and
> respective section gets executed. Is there a way that when its 3 AM,
> only 3 AM section should be executed and rest should be left
> untouched.
>
......
you could implement that using a case construct in the main script,
similar to....

CurHour=$(date +%H)

echo $CurHour

case $CurHour in

13)
echo found 13;;
14)
echo found 14;;
esac



From: OldSchool on
and...for what its worth, I think Icarus' solution, using linked
files, with a directory per hour, it probably cleaner.....