Ask the Expert

How do I schedule a cron job fortnightly?

How do I schedule a cron job fortnightly?

Requires Free Membership to View

A frustrating little problem. Set up cron so that it runs a script on the required day of every week, rather than on that day every second week. Inside the script put an 'if' statement. Calculate the current day as a number of days since any fixed time in the past, perhaps using date(1) for a bash/ksh/sh script. If the number of days is even, run your fortnightly job. If the number of days is odd, finish without running anything.

This was first published in May 2004

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: