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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crontab Entry to run every 45 Minutes

Status
Not open for further replies.

kozlow

MIS
Mar 3, 2003
326
0
0
US
I am trying to schedule a job to run every 45Minutes but am at a loss on how to accomplish.

Any ideas?
 
do a crontab -e

45 * * * * /usr/bin/whatever >/dev/null 2>&1

Thats minutes hours dayofmonth month weekday command
 
That is 45 past the hour --- Every 60Minutes......

In the mean time, I am going to run every 40 Minutes

Even Hour - 0,40
Odd Hour - 20
 
Your cron pattern will look like this:
Code:
00,45 0,3,6,9,12,15,18,21 * * *
30 1,4,7,10,13,16,19,22 * * *
15 2,5,8,11,14,17,20,23 * * *
If you plot out the 45-minute intervals, you will see that the minutes-after-the-hour repeats every three hours.
Code:
00:00
00:45
01:30
02:15
03:00
03:45
04:30
05:15
06:00
...and so on...
 
Like I said in the AIX forum (where you posted the same question)

enter the following on the command line

echo 0 > /tmp/count

use vi to create the following script

vi 45min.ksh

count=`cat /tmp/count`

if [ $count = "3" ] ; do
whatever_command
((count += 1))
echo $count > /tmp/count
done

if [ $count = "3" ] ; do
echo 0 > /tmp/count
done
fi

Then run this every 15 minutes from cron

00,15,30,45 9-17 * * * 45min.ksh

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."

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top