简体   繁体   English

Cron 作业无法在外部服务器上触发 Node.js 脚本

[英]Cron Jobs Fail to Trigger Node.js Script on External Server

I have a node.js application on a Windows Server and a series of cron jobs setup via cPanel on an external CENTOS server.我在 Windows 服务器上有一个node.js应用程序,并在外部 CENTOS 服务器上通过 cPanel 设置了一系列cron作业。 The cron jobs all target the URL of my node.js application using wget . cron作业都针对我的 node.js 应用程序的 URL 使用wget I confirmed that the jobs are running according to the cron logs in WHM, but they are not causing the script on the other server to run as they should.我确认作业正在根据 WHM 中的cron日志运行,但它们并没有导致其他服务器上的脚本按应有的方式运行。

The format of the cron jobs are like this: cron作业的格式如下:

wget -q -O - "http://example.com/app?&param=1&param=2" >/dev/null 2>&1

The result of the cron job should be the execution of the script on the other server. cron作业的结果应该是在另一台服务器上执行脚本。 That script uses Puppeteer to scrape web pages, take screenshots, parse the results into RSS feeds, and create rss formatted XML files on the file system.该脚本使用 Puppeteer 抓取 web 页面,截取屏幕截图,将结果解析为 RSS 提要,并在文件系统上创建 rss 格式的 XML 文件。 Despite the cron jobs firing and targeting the right URLs, I have yet to see a single cron job result in a new image or xml file being created.尽管cron作业触发并定位了正确的 URL,但我还没有看到单个cron作业导致创建新图像或 xml 文件。

This leads me to wonder if there is something I don't know about when it comes to cPanel, cron jobs and javascript .这让我想知道在 cPanel、 cron作业和javascript是否有我不知道的东西。 I'm thinking maybe they won't work with URLs leading to javascript files, but if that were true then wouldn't I have the same problem when executing the same commands via SSH?我在想也许他们不会使用指向javascript文件的 URL,但如果这是真的,那么在通过 SSH 执行相同的命令时我不会遇到同样的问题吗? I just tried one using the WHM terminal and it triggered the desired result.我刚刚使用 WHM 终端尝试了一个,它触发了预期的结果。

I think the issues was due to the firewall on the IIS server.我认为问题是由于 IIS 服务器上的防火墙造成的。 I added the remote IP address to the whitelist and now the cron jobs work.我将远程 IP 地址添加到白名单中,现在 cron 作业开始工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM