Skip Navigation

[Resolved] WP All Export Pro Cron job to hit Cron URL not working unless I deactivate Types

This thread is resolved. Here is a description of the problem and solution.

Problem:
You have a CPT created by Types, and deny read permissions to guests using Access to that CPT, then Export CRON Jobs run with the WP All Import plugin, do run, but do not export anything.

As soon as Access grants read permissions for guests on that CPT, OR Access is disabled, OR Access is restricting read access but you run the CRON manually in the Browser (logged in), the CRON properly runs and exports entries successfully.

Solution:
Set "read" to true for CPT guests permissions (CRON is a guest 🙂 )

There is one more solution, create a role copy of administrator, create a user and write a small plugin to open a session when WP runs from CRON. 'DOING_CRON' constant will help.

This support ticket is created 6 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 55 replies, has 3 voices.

Last updated by lindsayH 6 years, 3 months ago.

Assisted by: Beda.

Author
Posts
#618500

Please see hidden link - it's basically a Cron job that hits the Cron URLs.

If I run the URL 'manually' in a browser window all works fine.
If I create a Cron job from the cPanel the processing script does not export any records.

curl 'hidden link' -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36'

curl 'hidden link' -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36'

Also tried wget with same result.

If I deactivate just the Toolset Types plugin the above Cron jobs work as expected.

Is there anything that you can do to help both plugins to work together?

#618622

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Lindsay

I'll need to consult with colleagues in our server team about setting up a test to see if we can reproduce this problem, and if so identify the cause.

I'll get back to you.

#618957

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Lindsay

My colleague set up a test server and installed WP All Export Pro and added cron jobs as per the instructions and it worked okay without any errors.

She would like to take a look at your set-up to see if she can spot what the problem is.

Let me mark your next reply as private.

We will need not only the normal WP credentials, but also your hosting credentials, whatever is required to access your server and the cPanel, if that's okay.

#619233
processing.png
trigger.png

I removed all the code from my functions.php and it didn't make a difference.

export DISPLAY=:0 also didn't appear to help.

Email Notifications report everything is OK (see examples below):

curl action=trigger

% Total % Received % Xferd Average Speed Time Time Time Current

Dload Upload Total Spent Left Speed

0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0

0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0

100 50 100 50 0 0 29 0 0:00:01 0:00:01 --:--:-- 29

{"status":200,"message":"#24 Cron job triggered."}

curl action=processing

% Total % Received % Xferd Average Speed Time Time Time Current

Dload Upload Total Spent Left Speed

0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0

0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0

0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0

100 46 100 46 0 0 19 0 0:00:02 0:00:02 --:--:-- 19

{"status":200,"message":"Export #24 complete"}

But the All Export > Manage Exports, Summary column reports '0 Records Exported' after processing (see images).

Many thanks, Lindsay.

#620114

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Lindsay

My colleague has been testing this, so let me just repeat what she said to me:

I've run the manual curl command and those look to be working. If the manual command would work then the problem is how she added the curl.

Also, she added several things that are not necessary.

Based on her first comment, she said that she did:

curl 'hidden link' -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36'

This should be enough:
curl 'hidden link'

I'm thinking if the problem is on her setting in cPanel.

I'm logged on cPanel and I do not see any cron related to the export, can you ask her to set it up again so that we can check again?

Suggest her to use this as command curl 'hidden link'

Let me know if trying that helps and I'll pass on your feedback.

#620196

Many thanks.

Yes tried the simpler curl version first which also didn't work (the extra was added in case something was blocking calls that don't have user-agent headers). Also tried wget. Running manually is fine.

I will add again to cPanel (I removed it as triggering emails, so will add >/dev/null 2>&1 to the suggested simplified curl).

The trigger works fine, it's the processing that does not.

Thank you for all your help. Lindsay

#620525

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Lindsay

I passed that feedback to my colleague and she is going to check again later today after 5pm.

#622948

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Lindsay

My colleague had the following observations about using the curl command.

"When I do it, I do with -i in order to obtain some more details. The last line of what is returned is the following:

{"status":403,"message":"Export #24 is not triggered. Request skipped."}

The process isn't run due a 403 error, which is a permissions error."

Can you run your curl commands with the same -i parameter and see if you get the same?

Does that help identify the problem?

#622952

Hi, thank you for your continued help.

This is expected behaviour - and the same error would happen if I run the processing URL manually if I do NOT run the trigger URL first.

So basically you HAVE to run the trigger URL first (this does seem to work in the cron job). Then the processing URL will return {"status":200,"message":"Export #24 complete"} if then run manually. But doesn't seem to work in a cron job.

Maybe there is no solution... it's very strange I can run the processing URL manually but not in a cron job.

#623239

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Lindsay

My colleague ran more tests yesterday but the cron jobs didn't run.

She noticed the following:

the customer sets the following for the cron:
0 0 * * 0
this means that the 'trigger' cron will be processed only on Sunday. Can you suggest to her to set to:
0 0 * * *
as wpallimport asks to set 'Fetch this URL every 24 hours:' as described here: hidden link

#624562

Hi, thank you both for your continued support.

Yes - because it wasn't working I set to a longer time period. My tests were much more frequent that that. I'm happy if your colleague changes the cron job timings for testing purposes herself (and then perhaps sets back to a longer time period). This might be a better solution so she can set to suit the time she's actually investigating the issue.

The link indicates you can set the period to suit you:
"If you want to run your import every 24 hours, you should run the trigger URL every 24 hours. If you want to run your import once per week, you should run the trigger URL every week."

If she still wants me to set to daily though please do just let me know and I'll do for her, no problem. Lins

#625298

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Lindsay

My colleague reports that the cron job she set to run at midnight looks to be working, although it didn't export any records because, she surmises, there were no new records to export since the last export.

Basically, can you monitor what happens over the next few days and see whether it works?

#625305
firefox_2018-03-15_12-38-07.png

Hi, I just logged in to the back end of WordPress (All Export > Manage Exports) to have a look and sadly it hasn't worked (see image).

It should export ALL records and if I manually run the trigger URL first then the processing URL it works fine and would show here a total number of records exported (not 0). And the cron job also does work if I disable toolset.

Very strange.

#625313

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

"The cron job works if I disable Toolset".

The export is of a post type created with Types, no? So what does it export if you disable Types?

#625334

Hi Nigel.. because it's an SQL query (I guess) which is picking up the data directly from the database - which would still exist.

Thank you for your continued help. Lins