----- Original Message ----- 
From: "alben benavente alteza" <[EMAIL PROTECTED]>
To: "Philippine Linux Users Group Mailing List" <[EMAIL PROTECTED]>;
"Michael Chaney" <[EMAIL PROTECTED]>
Sent: Wednesday, July 21, 2004 9:25 AM
Subject: Re: [plug] bash script that will run a program at a certain
timeinterval


>As much as possible I don't want to use cron. I want my script to be self
>sufficient. I am also interested if such thing is possible.

it is possible... below is a sample template script to emulate cron which
wakes up every minute to see if there are jobs to be done...

#!/usr/local/bin/bash
while : ; do

        sDate=`date "+%w %m %d %H %M"`

        nDayOfTheWeek=${sDate:0:1}
        # Day Of The Week = 0 to 6
        # 0 as Sunday

        nMonth=${sDate:2:2}
        # Month = 01 to 12

        nDayOfTheMonth=${sDate:5:2}
        # Day Of The Month = 01 to 31

        nHour=${sDate:8:2}
        # Hour = 00 to 23

        nMinute=${sDate:11:2}
        # Minute = 00 to 59

        <your if then else statement goes here for first job>
        <another if then else statement here for the second job>
        <and so on and so forth>

        sleep 60
done

the if then else statement is a time comparison to invoke a particular
job...

for example.. if you want every 7 minutes a job to be executed, just use the
variable nMinute and modulos it to 7... if the result is zero then execute
that job... but of course, it is up to your logic and algorithm how to
simplify things...

fooler.

--
Philippine Linux Users' Group (PLUG) Mailing List
[EMAIL PROTECTED] (#PLUG @ irc.free.net.ph)
Official Website: http://plug.linux.org.ph
Searchable Archives: http://marc.free.net.ph
.
To leave, go to http://lists.q-linux.com/mailman/listinfo/plug
.
Are you a Linux newbie? To join the newbie list, go to
http://lists.q-linux.com/mailman/listinfo/ph-linux-newbie

Reply via email to