Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to schedule script without using cron 2

Status
Not open for further replies.

adaaje

Technical User
May 26, 2006
60
AU
Hi guys,

I would like to run my script every day at 8.00 am and 10.30 am except saturday and sunday, but I don't have cron installed in my account.

How do I do that ?

Thanks in advance
 
Ask your sysadmin to create the cron job for you.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Or how about annicron :) :

Code:
#!/bin/ksh

TIMES="0800 1030"
DAYS="1 2 3 4 5"
JOB="uptime"

while true
do
        sleep 50 # check at least once a minute
        for DAY in $DAYS
        do
                if [[ "$(date +%w)" -eq "$DAY" ]]
                then
                        for TIME in $TIMES
                        do
                                if [[ "$(date +%H%M)" -eq "$TIME" ]]
                                then
                                        $JOB &
                                        # make sure we do
                                        # not run twice
                                        sleep 20
                                fi
                        done
                fi
        done
done

Replace uptime with your job of course, and run this script in the background, probably best with nohup.

Annihilannic.
 
Hi Annihilanic,

what a great script ? But I have some questions for you...
when you check every 50 secs.. why not 60 secs (=1 mnt)?

and why
$JOB & sleep 20

not
$JOB [only]

Thx mate...
 
Well, if you check every 60 seconds, there is a very small chance on a busy system that it will check once at 07:59:59, and the next time at 08:01:00, so your job would not run.

$JOB & runs the job in the background, so that the annicron keeps running, in case the jobs overlap or take a long time, etc. You can take out the & of course if you want, and that would make sure they would never overlap.

sleep 20 is to make sure it doesn't run a job twice in one minute, e.g. at 08:05 and 08:55.

Annihilannic.
 
Thx a lot man...
Is there any chance you would go to Sydney ?
If yes, let me know. I'll treat you some lunch/dinner :p

Have a star...
 
Would you believe I'm actually planning to move to Sydney as soon as I can! :)

Annihilannic.
 
Really ??? where are you now ?? when??
 
And UNIX job is quite pick up in here, I can refer you to my agent if you like lol...
 
Know any good agents in NZ, planning on relocating from UK next year.

Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
Hmm.. why not moving to Sydney ??
better money, better living, in NZ is so quite heheh...

Sorry mate, no idea in NZ.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top