简体   繁体   English

为什么我的卷曲Cron工作无法运行?

[英]Why is my curl cron job not running?

I am trying to figure out why my curl cron job is not executing correctly. 我试图弄清楚为什么我的curl cron作业无法正确执行。 When I run it in the browser it runs just fine however if I run it in command line I get the following output. 当我在浏览器中运行它时,它运行得很好,但是如果我在命令行中运行它,则会得到以下输出。 I have replaced the actual URL however the url is something like example.com/file.php?pass=password&t=d 我已经替换了实际的网址,但是该网址类似于example.com/file.php?pass=password&t=d

root@low [/home/user]# sudo -u user curl URL root @ low [/ home / user]#sudo -u用户curl URL
[1] 13959 root@low [1] 13959 root @ low
[/home/user]# Starting backups for 0 accounts! [/ home / user]#开始备份0个帐户!

The output in the browser runs for all 9, 10, or however many backups I have. 浏览器中的输出针对所有9、10或我拥有的许多备份运行。 Am I just missing a flag in my curl request? 我只是在卷曲请求中缺少标志吗?

You are using the & sign in the command line, so the parameter t gets lost and your script does not get all its input data (and it's probably the same with your cron job, since it's executed shell-wise). 您在命令行中使用&符号,因此参数t丢失并且您的脚本无法获取其所有输入数据(由于Cron作业是通过Shell方式执行的,因此它可能与cron作业相同)。

try: 尝试:

curl 'url' 卷曲'url'

Checkout http://linuxcommand.org/lts0080.php , search for "Putting a program in the background" for more info on & in the shell. 检出http://linuxcommand.org/lts0080.php ,在外壳中搜索“在后台放置程序”以获取更多信息。

I believe curl is typically located in /usr/bin/curl . 我相信curl通常位于/usr/bin/curl Perhaps you need to run it as absolute path in your cronjob (in case /usr/bin is not contained in your default path). 也许您需要在cronjob中将其作为绝对路径运行(以防默认路径中不包含/usr/bin )。 This would typically be the case if it works from commandline but not from cron (as exact same command). 如果它可以从命令行运行,而不能从cron运行(完全相同的命令),通常就是这种情况。

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

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