【问题标题】:i want to make cron job for the url of nodejs我想为nodejs的url做cron作业
【发布时间】:2017-05-11 12:21:18
【问题描述】:

在邮递员内部,我的网址“http://localhost:1000/api/coupon/coupondeactivate”工作正常。我想在 cron 作业中创建这个 URL。所以我以下面的形式使用它。

wget http://localhost:1000/api/coupon/coupondeactivate --header "Referer: localhost:1000"

但是当我尝试在 CMD 中粘贴上面的 URL 时,我发现了下面的错误,所以请帮我解决这个问题。

Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:1000... connected.
HTTP request sent, awaiting response... 404 Not Found
2016-12-27 12:27:19 ERROR 404: Not Found.

【问题讨论】:

  • 您是否尝试过改用 Postman 生成的cURL 命令? (这不是 wget... 但也许它会帮助您更快地获得答案?)getpostman.com/docs/creating_curl 否则,我建议从服务器的角度检查 Postman 与 wget 请求,看看它们有什么不同。
  • 你好 therobinkim,我也在 cmd 中尝试了 curl 命令并写 curl -s localhost:1000/api/coupon/coupondeactivate
  • 当时Cannot GET /api/coupon/coupondeactivate错误来了
  • 此时您的服务器表现如何?它是否确认收到请求?
  • 此端口上的网站工作正常

标签: node.js ubuntu url cron


【解决方案1】:

您好,请为您的网址尝试以下 curl 请求。

watch -n 5 curl --request POST  urlname

在 cmd 上面运行它对我来说工作正常

【讨论】:

  • 它每 5 秒运行一次 url,您可以通过删除 5 秒来增加您的时间并放入您自己的时间
猜你喜欢
  • 2021-03-25
  • 2022-12-07
  • 2013-02-01
  • 2021-05-10
  • 1970-01-01
  • 2020-06-10
  • 1970-01-01
  • 2020-04-14
  • 2018-06-25
相关资源
最近更新 更多