Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,676 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,198 people online right now. Registration is fast and FREE... Join Now!




Setting up cron jobs

 
Closed TopicStart new topic

Setting up cron jobs, to run every 2nd week

edu2004eu
post 19 Sep, 2008 - 08:19 AM
Post #1


New D.I.C Head

Group Icon
Joined: 26 Aug, 2007
Posts: 41



Dream Kudos: 25
My Contributions


Hi. I have CPanel on my free host and the standard cron editor doesn't have a 'run every 2nd week' option. So can anybody tell me what to write in the advanced cron editor so that it runs at 2 weeks.

For example: this friday it runs, next friday not, the following friday it runs, then not... and so on (no, I don't want it to run on the second week of the month only).

Any help would be appreciated.

Thank you.
User is offlineProfile CardPM

Go to the top of the page

Trogdor
post 25 Sep, 2008 - 05:00 AM
Post #2


D.I.C Addict

Group Icon
Joined: 6 Oct, 2006
Posts: 517



Thanked 3 times

Dream Kudos: 125
My Contributions


the easy way out would seem:

#minute hour mday month wday command
* * */14 * * /etc/do/something.sh

however, the distance between executions will be bigger then 14 days after a long month: first execution on day 14, second on day 28, third on day 14 of the next month which is 17 days after the second.

why not let it run every friday, and inside the script just exit if its the wrong week.
User is offlineProfile CardPM

Go to the top of the page

Hary
post 25 Sep, 2008 - 11:41 AM
Post #3


D.I.C Head

**
Joined: 23 Sep, 2008
Posts: 190



Thanked 14 times
My Contributions


It is not possible to switch on week, so bi-weekly is not possible the way tou like it. The weekly solution, and a check for week number is the best solution:
@weekly <script>
or 0 0 * * 0 <script>

(From the man page: Note: The day of a commandâs execution can be specified by two fields day of month, and day of week. If both fields are restricted (i.e.,aren't *), the command will be run when either field matches the current time.)
User is online!Profile CardPM

Go to the top of the page

edu2004eu
post 26 Sep, 2008 - 04:49 AM
Post #4


New D.I.C Head

Group Icon
Joined: 26 Aug, 2007
Posts: 41



Dream Kudos: 25
My Contributions


Sad... it's a feature they should add... thank you anyway... smile.gif
User is offlineProfile CardPM

Go to the top of the page

Closed TopicStart new topic
Time is now: 11/23/08 06:27AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month