Link to home
Start Free TrialLog in
Avatar of chewlf
chewlf

asked on

How to setup Crontab to run the job fortnightly

To all the expert,

Anyone know how to write the crontab to run the job fortnightly? Not type of 1st and 3rd week of the month (typical example) because the accuracy is not there. What I want is the crontab able to run the job exactly two weeks once. Please advice.

Thanks,
Chewlf
ASKER CERTIFIED SOLUTION
Avatar of Tintin
Tintin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of chewlf
chewlf

ASKER

what about any simple/direct script in crontab to schedule the job? for example, 00 12 * * * /dir/script to schedule to run the script on everyday noon.

Thanks,
Chewlf
Do you want to run the script everyday in ONE week ON and ONE week OFF mode.

My first script should work for you.

It this is not what you want, please let us know exactly what you want to do.
To have a script schedule a cron job, it should:
  1st - copy the crontab file to a temp file.
  2nd - append the job to the temp file.
  3rd - run crontab with the tempfile as its argument.
        This will replace the existing crontab file.

To unschedule the cron job:
  1st - sed the crontab file to remove the job.
        Redirect the sed output to a temp file.
  2nd - run crontab with the tempfile as its argument.
        This will replace the existing crontab file.

If you need exact commands, let me know.