通过 Cron 调用 URL 时正在创建不需要的文本文件
Unwanted text file is creating while calling a URL through Cron
在我们的应用程序中,我们为 运行 配置了 Cron 作业的数量,一些例程 tasks.We 正在 Ruby Rails 上工作。我会提供我们正在使用的流程。
crontab
*/2 * * * * user sh file_path/test.sh
test.sh
wget https://domain.com/url/key
routes.rb
post "/url/:key" => "cron_job_controller#action"
cron_job_controller.rb
def action
if params[:key] && params[:key] == "key"
---do some actions----
end
respond_to do |format|
format.html {render :status => Rack::Utils.status_code(:ok), :nothing => true}
end
end
作业正在执行,所有过程都已成功完成。但在收到响应 200 后,生成了一个不需要的文本文件,其名称作为我们传递到主文件夹中的键的值。例如 key、key.1、key.2 等....。提供以下控制台结果。
LAP-PS009:~/work$ sh file_path/test.sh
--2015-02-13 14:58:16-- http://localhost:3000/url/key
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:3000... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `key'
[ <=> ] 1 --.-K/s in 0s
2015-02-13 14:58:18 (89.3 KB/s) - `key' saved [1]
因此,我们必须手动监视和删除这些不需要的文件。所以我要求为这个问题提出一个永久的解决方案。等待重播。提前致谢。
无论您是否只需要选择一个 API 端点,您都可以将 curl
与相应的 CRUD 操作一起使用 (POST
/PUT
/DELETE
).
一旦你坚持 wget
,请执行以下操作:
wget https://domain.com/url/key -o /dev/null -O /dev/null
上面的代码会将输出重定向到任何地方,以防止目录被垃圾化。
在我们的应用程序中,我们为 运行 配置了 Cron 作业的数量,一些例程 tasks.We 正在 Ruby Rails 上工作。我会提供我们正在使用的流程。
crontab
*/2 * * * * user sh file_path/test.sh
test.sh
wget https://domain.com/url/key
routes.rb
post "/url/:key" => "cron_job_controller#action"
cron_job_controller.rb
def action
if params[:key] && params[:key] == "key"
---do some actions----
end
respond_to do |format|
format.html {render :status => Rack::Utils.status_code(:ok), :nothing => true}
end
end
作业正在执行,所有过程都已成功完成。但在收到响应 200 后,生成了一个不需要的文本文件,其名称作为我们传递到主文件夹中的键的值。例如 key、key.1、key.2 等....。提供以下控制台结果。
LAP-PS009:~/work$ sh file_path/test.sh
--2015-02-13 14:58:16-- http://localhost:3000/url/key
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:3000... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `key'
[ <=> ] 1 --.-K/s in 0s
2015-02-13 14:58:18 (89.3 KB/s) - `key' saved [1]
因此,我们必须手动监视和删除这些不需要的文件。所以我要求为这个问题提出一个永久的解决方案。等待重播。提前致谢。
无论您是否只需要选择一个 API 端点,您都可以将 curl
与相应的 CRUD 操作一起使用 (POST
/PUT
/DELETE
).
一旦你坚持 wget
,请执行以下操作:
wget https://domain.com/url/key -o /dev/null -O /dev/null
上面的代码会将输出重定向到任何地方,以防止目录被垃圾化。