Operating System - HP-UX
1833798 Members
3063 Online
110063 Solutions
New Discussion

How do I create a cron job?

 
SOLVED
Go to solution
finas
Advisor

How do I create a cron job?

Dear HP-UX Experts,
If I want to automate the cron job to be run at 12 noon and 5 p.m, on 15th,27th, and 28th of every month, every month during week days.
Is it ok if I put like this?

00 12,17 15,27,28 * 1-5

Thanks a bundle. Hope to hear from you soon.
10 REPLIES 10
Dennis Handly
Acclaimed Contributor

Re: How do I create a cron job?

Using 15,27,28 and 1-5 ORs them not ANDs them.
From your words above, that sounds like you want inclusive OR?

If you want AND you'll need to put one of these checks into your script.
finas
Advisor

Re: How do I create a cron job?

Hi Sir,
Thanks for the reply
If I understand you correctly, basically
I would like the the monitoring to run (00 12,17) 12.00 noon and 17.00 p.m.(15,27,28 *) on 15th, 27th and 28th of every month (1-5) from monday to friday. Will it run what I want it to be?
Irappa
New Member

Re: How do I create a cron job?

Hi,

00 12,17 15,27,28 * 1-5 >>your cron activity.

This must work according to your requirement.


Regards.
finas
Advisor

Re: How do I create a cron job?

I've editted the crontab file this morning. I've directed the monitoring output to my email. Surprisingly it sent me an email today at 12 noon. but today is 12th of the month. i set it to run on 15th,27th and 28th? would really appreciate your advise?
Mridul Shrivastava
Honored Contributor

Re: How do I create a cron job?

Do you mean to say that if dates 15,27,28 are falling on saturday or sunday then this cron job should not run ?
Time has a wonderful way of weeding out the trivial
Mridul Shrivastava
Honored Contributor
Solution

Re: How do I create a cron job?

as per the entries in the crontab it is doing correct.. see as per the above entries.. It will run the job if it is 15,27,28 or Mon-Friday. If anyone of these matches then this will execute the job.

Now you want it to run on 15,27,28 only if it falls on Mon-Friday then in crontab you should have an entry like

00 12,17 15,27,28 * *

Then in the script it self you need to check either it is Mon-Friday or not?

I don't find anything to do multiple checks using crontab for AND operations....
Time has a wonderful way of weeding out the trivial
Dennis Handly
Acclaimed Contributor

Re: How do I create a cron job?

As I said before, you can't use English to describe it. Or you must use lots more words than you have.

Or you must use C boolean operators.

>(15,27,28) on 15th, 27th and 28th of every month (1-5) from monday to friday.

So you want it to run on 15,27,28 ONLY when it is also Monday-Friday? Boolean AND.

>Mridul: Then in the script ... you need to check either it is Mon-Friday

DOW=$(date +'%w')
if [ $DOW -eq 0 -o $DOW -eq 6 ]; then
exit 0 # exit on Sun or Sat
fi

>Mridul: I don't find anything to do multiple checks using crontab for AND operations

tztab(4) lets you do AND, so don't confuse them.
Dennis Handly
Acclaimed Contributor

Re: How do I create a cron job?

Since you are new to the forum, please read how to assign points:
http://forums1.itrc.hp.com/service/forums/helptips.do?#33
finas
Advisor

Re: How do I create a cron job?

Hiii Mr Mridul, Denis and Irappa,
You are all very helpful.... Thanks a lot. I need clear cut example to understand this new field. Thanks a lot. I'm sorry if you are not happy with the points I rated. No worries, I'll post lotsa more questions here. :) Thank you
finas
Advisor

Re: How do I create a cron job?

replace 1-5 with *