1753814 Members
7764 Online
108805 Solutions
New Discussion юеВ

Re: Cron help

 
Patrick Wallek
Honored Contributor

Re: Cron help

>>will this work?
>>00 08 1-7,15-21 * 3 /home/oracle/test.sh

No, I don't think this will do what you want. This job will run on the 1-7, the 15-21 AND on Friday. The job will run IF ANY of the last 3 fields are true.

Note the example from the cron man page:


Note that the specification of days can be made in two fields: monthday and weekday. If both are specified in an entry, they are cumulative. For example,

0 0 1,15 * 1 command

runs command at midnight on the first and fifteenth of each month, as well as every Monday.


>>Do all months have exactly 28 days?
Well, yes they do! ;)
Steven Schweda
Honored Contributor

Re: Cron help

> >>Do all months have exactly 28 days?
> Well, yes they do! ;)

This must be some new meaning for the word
"exactly" (which I used for a reason).
balaji_vvv
Frequent Advisor

Re: Cron help

I finally ended up using Larry Klasmier idea.

Thanks for everyone contributed.
Here is the logic, if anyone needs it.
This will run biweekly sunday at 10.00am.

My cron
--------
00 10 * * 6 /myscript

My script
---------

#! /usr/bin/bash

if [ -e /tmp/fchek ] ; then
rm -f /tmp/fchek
else
touch /tmp/fchek
exit 0
fi

sh /myscript

exit 0

Explanation : (Not for experts!)
-------------
Script will look for a file /tmp/fcheck on the first run, it wont find it and it will create and exit. On the next week it will find the file, remove it and execute my script. On third week it wont find my file, create it and exit and so on....
balaji_vvv
Frequent Advisor

Re: Cron help

Resolved. See above
Steven Schweda
Honored Contributor

Re: Cron help

> rm -f /tmp/fchek
> else

If someone changes the permissions on this
file, then the "rm" could fail (silently).

Of course, this should never happen. How
important is it that this job run exactly
every two weeks? Sometimes the easy way is
good enough. Sometimes it's not. You get to
decide what's good enough.
balaji_vvv
Frequent Advisor

Re: Cron help

I will keep this file in secure location. It's not very critical if it fail to run, as everyone in that group will get email, and they will take care of it.