Score:0

Use EasyCron to make cURL request with cronjob

io flag

I want to make a cURL request every 12 hours and trigger the request with a cronjob. Unfortunately I'm a total newbie in cURL and cronjobs.

This is the request I want to make:

curl --location --request POST 'https://example.com/wp-admin/admin-ajax.php' \
--form 'action="algolia_re_index"' \
--form 'index_id="searchable_posts"' \
--form 'p="1"'

The request should be triggered by a cronjob via EasyCron. I need to add simple URLs there.

So I tried this:

curl -s "https://example.com/wp-admin/admin-ajax.php' \ --form 'action="algolia_re_index"' \ --form 'index_id="searchable_posts"' \ --form 'p="1"'"

But that's not working.

I don't understand how I add the parameters to the URL. Do I need to add something on my server/site?

Here's the article about the topic.

in flag
Remove the backslashes. They escape the newline and are just there to make the command multiline to make it better readable.
Cray avatar
io flag
I tried this: `https://example.com/wp-admin/admin-ajax.php&action=algolia_re_index&index_id=searchable_posts&p=1` but the cronjob fails because of an 404 error
in flag
Well, that's a default WordPress URL. If you get a 404 your problem is on the server side, not on the curl side.
Cray avatar
io flag
Okay @GeraldSchneider, I will check that
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.