/    Sign up×
Community /Pin to ProfileBookmark

How to rerun a php script without loading it in a browser again?

I use WordPress. I have a php script I load into each post, via shortcode, that runs a 24 hour auction for the item in that post.

At the end of the auction I need to trigger an email function in the script which notifies the winning bidder.

I can’t depend on there being a user that will initiate a browser reload at that specific time. So I need an automatic way to do it without a browser.

I would like to programmatically create a crontab when the first person loads the page. It would simply wget the page every minute until perhaps a couple minutes after the auction ends. At which point I would programmatically delete the crontab.

Sooooo, does anyone know how to create a crontab using php??
I have tried this:

[code=php]exec(‘crontab -e * 20 * * * wget -q -O /dev/null “‘ . $url . ‘” >/dev/null 2>&1’);[/code]

But I can’t get any confirmation that it is working.

Any ideas would be greatly appreciated!

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogFeb 09.2017 — Might be easier to have PHP write something to a DB (or a file) that would define info about a given auction, then have your crontab run a script every X minutes that would read that data and determine if/when an auction had completed and trigger the relevant actions.
Copy linkTweet thisAlerts:
@dwestauthorFeb 09.2017 — Good idea! I'll throw it in the tumbler and see what comes out ?

Thank you!


Might be easier to have PHP write something to a DB (or a file) that would define info about a given auction, then have your crontab run a script every X minutes that would read that data and determine if/when an auction had completed and trigger the relevant actions.[/QUOTE]
×

Success!

Help @dwest 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 5.7,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...