0

How to enable cron entry for bi-weekly basis (every other week) . For example if cron runs on 05/05/2017(Friday) , It should run on 19/05/2017(Friday)

Balu
  • 33
  • 2
  • 4
  • Seems question already asked here : [cronjob-every-two-weeks](https://stackoverflow.com/questions/34055122/cronjob-every-two-weeks) [how-to-instruct-cron-to-execute-a-job-every-second-week](https://stackoverflow.com/questions/350047/how-to-instruct-cron-to-execute-a-job-every-second-week) – jirarium May 24 '17 at 14:27

2 Answers2

0

Execute the cron every week and test inside the file if do or not something. For example:

<?php
if (date("W")%2 == 0) {
 //do something
} else {
 //wait
}
?>
Carmen
  • 181
  • 7
  • Actually I have to call the shell(in unix environment) like below(example) 00 07 * * * . ./.profile; cd xxx/export-xxx-qa; ksh export-xxx-wlymp.ksh So, need to handle logic in cron entry. I have to call the shell "export-xxx-wlymp.ksh" bi-weekly basis (every other week) – Balu May 24 '17 at 14:35
  • Glad to help Balu. Please mark question as answered if you considered it solved. – Carmen May 24 '17 at 14:52
0

This should run every friday:

0 0 1-31 1-12 5  someScript.sh

This will check if it's an odd week:

someScript.sh

#!/bin/sh
WEEK_OF_YEAR=`/bin/date +%V`
echo $WEEK_OF_YEAR
if [[ $(($WEEK_OF_YEAR % 2)) -eq 1 ]];
then
  echo "DO SOMETHING" 
fi
ergonaut
  • 6,929
  • 1
  • 17
  • 47