Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 如何知道curl脚本是否有效_Xml_Apache_Shell_Curl - Fatal编程技术网

Xml 如何知道curl脚本是否有效

Xml 如何知道curl脚本是否有效,xml,apache,shell,curl,Xml,Apache,Shell,Curl,因此,我尝试使用cURL下载一个托管在web上的xml文件(https://),每五分钟下载一次。因此,我创建了一个crontab来定期激活脚本: */5 * * * * /usr/bin/curl /var/www/html/script.sh My script.sh如下所示(它与StationSchedule.xml文件位于同一目录中): #/bin/bash curl-o“StationSchedule.xml”“” 我使用crome开发工具找到的标题 但是,xml文件似乎没有按应有

因此,我尝试使用cURL下载一个托管在web上的xml文件(https://),每五分钟下载一次。因此,我创建了一个crontab来定期激活脚本:

*/5 * * * * /usr/bin/curl /var/www/html/script.sh
My script.sh如下所示(它与StationSchedule.xml文件位于同一目录中):

#/bin/bash
curl-o“StationSchedule.xml”“”
我使用crome开发工具找到的标题


但是,xml文件似乎没有按应有的方式更新,我的问题是什么?谢谢。

您的crontab不正确,因为您试图使用shell脚本作为其第一个参数运行curl,而这将永远不会起作用

  • 从crontab中删除/usr/bin/curl
  • 将/var/www/html/script.sh上的执行权限设置为
    chmod+x/var/www/html/script.sh
  • 提供StationSchedule.xml文件的完整路径。例如
    curl-o”/tmp/StationSchedule.xml“

  • 我已经尝试了这三个步骤,但是文件仍然没有更新。我怎么知道呢?(对不起,这是我第一次这样做)在您的终端上,只需运行/var/www/html/script.sh-bash:/var/www/html/script.sh:/bin/bash^M:bad解释器:没有这样的文件或目录我正在使用putty对服务器进行ssh
    #!/bin/bash
    
    curl -o "StationSchedule.xml" "<URL_OF_THE_WEBSITE>"