/    Sign up×
Community /Pin to ProfileBookmark

Is it possible to execute a cron job every other day, or every third day?

to post a comment
Full-stack Developer

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogAug 07.2005 — Probably the closest you could come would be every other (or every third) day of the month. The pattern would break down at the end of each month if it's not divisible evenly by two (or three):
<i>
</i>30 1 2-30/2 * * echo "run at 1:30am on even-numbered days of the month"
Copy linkTweet thisAlerts:
@Stephen_PhilbinAug 07.2005 — How about doing it in a two-step approach?

Could you make a shell script that, when executed, sets up the desired cron job if absent, and deletes the desired cron job if present. Then have a daily cron job to execute that shell script.That way the first one alternates the presence of the second job which would then get executed one minute later if present by the previous one writing it. Does that make sense or should I just give up trying to speak English?
Copy linkTweet thisAlerts:
@amazing_andr3authorAug 07.2005 — NogDog: unfortunately that's not precise enough.

Mr Herer: unfortunately it's not my server and I don't think I can set cron jobs automatically

Thanks anyway, at least now I know it's not possible to do that with cron. Then I'll just run the cron every day and start my script with

[code=php]if(date('z') % 2 !== 0) exit;[/code]
Copy linkTweet thisAlerts:
@Stephen_PhilbinAug 07.2005 — Oh yeah. How ridiculously obvious. I'm not even gonna try and think about why I thought of the solution I did and not the one you thought of. It's bound to hurt.
×

Success!

Help @amazing_andr3 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...