SOLVED Cross Domain Cron Jobs Not Working

Operating System & Version
CENTOS 7.9
cPanel & WHM Version
94.0.4

PostAlmostAnything

Active Member
Mar 3, 2020
26
0
1
Portland, Oregon
cPanel Access Level
Website Owner
I have a series of cron jobs that are not firing. They are supposed to open the URL of an API on another server. I own the other server, but since it is a Windows Server I though it would be easier for me to automate the running of those scripts using cron jobs on my Linux server. I know cron jobs in general are working just fine, but until now I have never tried to open a URL on a different server using wget.

The wget commands work just fine using SSH, but for whatever reason the cron jobs are not working. The only difference in coding between the cron jobs and the code I ran in SSH is that the cron jobs end with >/dev/null 2>&1

An example of the format of my cron jobs are as follows:

wget -q -O - "http://example.com/api?param1=1&param2=2" >/dev/null 2>&1

Is there anything built into cPanel that might block these kinds of cross server cron jobs from working?
 

PostAlmostAnything

Active Member
Mar 3, 2020
26
0
1
Portland, Oregon
cPanel Access Level
Website Owner
I checked the cron log and it looks like the jobs are running but without the tail end of them. The second " and >/dev/null 2>$1 are not in the cron log when they are run.

Here is an example with the exact destination edited out:

Mar 31 00:00:01 93-95-228-111 CROND[16526]: (brokenborder) CMD (wget -q -O - "http://example.com/app?&url=https:/...ex&cat=example&format=html&le=.post-thumbnail)

The cron job specified in cPanel says:

wget -q -O - "http://example.com/app?&url=https:/...-thumbnail>a&ce=.post-text&spoof=false&size=5" >/dev/null 2>&1


It appears that having %3E appear after post-thumbnail is enough to cut off the rest of the job. That is an encoded > symbol that needs to be included so that it can be passed to a queryselector with a css class and an instruction to get the anchor element inside of it.
 
Last edited:

PostAlmostAnything

Active Member
Mar 3, 2020
26
0
1
Portland, Oregon
cPanel Access Level
Website Owner
It seems even the jobs without that character that do run to the right place are not triggering the script on the other end.

Are cron jobs compatible with javascript? All the URLs in question are javascript apps built with Node.js
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
4,482
565
273
cPanel Access Level
Root Administrator
Hey there! This seems more like a wget or BASH issue than a cron problem itself, since cron is just doing what it is told. I did find this guide about escaping special characters with wget:


so it might be worth trying that to see if that gets things working how you expect.
 

PostAlmostAnything

Active Member
Mar 3, 2020
26
0
1
Portland, Oregon
cPanel Access Level
Website Owner
Can you let me know what you mean when you say "not triggering the script on the other end"? Cron itself has no concept of javascript or bash or anything, as it just triggers the processes to happen at a certain time.
I mean that the script on the other end is not running when the cron job runs. The URLs given to the cron job are the same URLs that work fine when loaded in a browser and they work just fine when using wget manually via SSH, but when I use a cron job they do not run.

I know they do not run because they are always supposed to update XML files on the other server when they run and the files remain unmodified no matter how many cron jobs are run.
 

PostAlmostAnything

Active Member
Mar 3, 2020
26
0
1
Portland, Oregon
cPanel Access Level
Website Owner
Did you try the special character escape trick to see if that changed the behavior?
Sorry for not updating this. I tried simply using a + character and coding my script to convert + characters to > characters for the purpose of queryselector. Now they work. I also added an inbound rule granting access to the IP address of the server running the cron jobs. Now they work